mhanberg / mhanberg/jekyll-postcss

PostCSS config, plugins as an object (as opposed to an array) fails

Open
#21 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
70
Forks
12
PR merge metrics
No merged PRs in 30d

Description

With the following postcss.config.js:

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
};

This gem fails with the following message:

Configuration file: /Users/foo/project/_config.yml
            Source: /Users/foo/project
       Destination: /Users/foo/project/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
PostCSS Server listening on port 8124...
/Users/foo/project/node_modules/postcss/lib/processor.js:60
        throw new Error(i + ' is not a PostCSS plugin')
        ^

Error: [object Object] is not a PostCSS plugin
    at Processor.normalize (/Users/foo/project/node_modules/postcss/lib/processor.js:60:15)
    at new Processor (/Users/foo/project/node_modules/postcss/lib/processor.js:9:25)
    at postcss (/Users/foo/project/node_modules/postcss/lib/postcss.js:25:10)
    at Function.process (/Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.0/bin/postcss:9:5)
    at Socket.<anonymous> (/Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.0/bin/postcss:21:14)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
  Conversion error: Jekyll::Converters::PostCss encountered an error while converting 'styles.css':
                    undefined method `chomp' for nil:NilClass
                    ------------------------------------------------
      Jekyll 4.2.0   Please append `--trace` to the `serve` command
                     for any additional information or backtrace.
                    ------------------------------------------------
Traceback (most recent call last):
	43: from /Users/ali/.rbenv/versions/2.7.2/bin/bundle:23:in `<main>'
	42: from /Users/ali/.rbenv/versions/2.7.2/bin/bundle:23:in `load'
	41: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/exe/bundle:37:in `<top (required)>'
	40: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
	39: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/exe/bundle:49:in `block in <top (required)>'
	38: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli.rb:24:in `start'
	37: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	36: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli.rb:30:in `dispatch'
	35: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	34: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	33: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	32: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli.rb:494:in `exec'
	31: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli/exec.rb:28:in `run'
	30: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli/exec.rb:63:in `kernel_load'
	29: from /Users/ali/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.14/lib/bundler/cli/exec.rb:63:in `load'
	28: from /Users/foo/project/vendor/bundle/ruby/2.7.0/bin/jekyll:23:in `<top (required)>'
	27: from /Users/foo/project/vendor/bundle/ruby/2.7.0/bin/jekyll:23:in `load'
	26: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/exe/jekyll:15:in `<top (required)>'
	25: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
	24: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
	23: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
	22: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
	21: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
	20: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
	19: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
	18: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `each'
	17: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
	16: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/commands/build.rb:36:in `process'
	15: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/commands/build.rb:65:in `build'
	14: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:28:in `process_site'
	13: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:80:in `process'
	12: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:211:in `render'
	11: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:538:in `render_pages'
	10: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:538:in `each'
	 9: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:539:in `block in render_pages'
	 8: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:547:in `render_regenerated'
	 7: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:63:in `run'
	 6: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:84:in `render_document'
	 5: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:104:in `convert'
	 4: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:104:in `reduce'
	 3: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:104:in `each'
	 2: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-4.2.0/lib/jekyll/renderer.rb:106:in `block in convert'
	 1: from /Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.0/lib/jekyll/converters/postcss.rb:41:in `convert'
/Users/foo/project/vendor/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.0/lib/jekyll-postcss/socket.rb:28:in `read': undefined method `chomp' for nil:NilClass (NoMethodError)
error: Script failed: see failed command above

However this syntax works as expected:

module.exports = {
  plugins: [
    require('tailwindcss'),
    require('autoprefixer'),
  ],
};

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/jekyll-postcss/socket.rb and lib/jekyll/converters/postcss.rb, then inspect bin/postcss where the stack trace shows configuration is passed to PostCSS. Reproduce the issue with the object-form postcss.config.js and verify that the Jekyll build succeeds while the existing array-form configuration continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, ruby, tailwindcss
Domain
build-system, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.