ember-cli-postcss icon indicating copy to clipboard operation
ember-cli-postcss copied to clipboard

Cannot use `cssnano` in version 7

Open boris-petrov opened this issue 4 years ago • 5 comments

Here is a reproduction. Note that this is a branch in the repo, the master branch is for a different issue.

Using cssnano doesn't work at all with ember-cli-postcss version 7. It seems to pass the plugins defined in the filter block in ember-cli-build as plugins to cssnano (which I guess has some plugin mechanism) and that breaks badly as it expects completely different things.

To reproduce - clone the repo, checkout the branch, npm install, ember serve.

boris-petrov avatar Nov 21 '21 20:11 boris-petrov

Is it possible to set the plugins for cssnano to an empty array?

filter: {
        enabled: true,
        plugins: [
          { module: require('autoprefixer') },
          { 
            module: require('cssnano'),
            options: { plugins: [] }
          },
        ],
      },

jeffjewiss avatar Nov 22 '21 14:11 jeffjewiss

@jeffjewiss - indeed, that does fix the issue! However, this is a workaround and not a real fix so let's keep the issue open until it's fixed. Thank you! :)

boris-petrov avatar Nov 22 '21 14:11 boris-petrov

Glad to hear that fixed it. I think it's because we're merging the options recursively, but I'm not sure when I'll have a chance to work on a fix.

jeffjewiss avatar Nov 22 '21 15:11 jeffjewiss

Spoke too soon. That makes the error go away but for some reason cssnano does nothing. That is, the produced CSS is the same with or without adding the cssnano module. That wasn't the case with ember-cli-postcss v6. Any ideas (apart from fixing the bug in ember-cli-postcss)? :smile:

boris-petrov avatar Nov 24 '21 09:11 boris-petrov

I ran into this and options: { preset: 'default' } fixed it for me.

gitKrystan avatar Jul 25 '22 21:07 gitKrystan

@gitKrystan thanks for sharing a working config.

I'm going to close this out since that config should solve the issue.

jeffjewiss avatar Aug 27 '22 17:08 jeffjewiss