zgreen / postcss-critical-css

PostCSS plugin to define and output critical CSS using custom atRules, and/or custom CSS properties. Critical CSS may be output to one or more files, as defined within the plugin options or within the CSS.
MIT License
86 stars 12 forks source link

Emits "You did not set any plugins, parser, or stringifier. Right now, PostCSS does nothing..." warning if scss entrypoint are passed to Webpack config #48

Open bitfella opened 5 years ago

bitfella commented 5 years ago

Hello, postcss-crititical-css emits the following annoying console warning several times:

40% building 5/7 modules 2 active ...s\sass-loader\dist\cjs.js!C:\Migu\postcss-critical-css-test-master\src\module.scssYou did not set any plugins, parser, or stringifier. Right now, PostCSS does nothing. Pick plugins for your case on https://www.postcss.parts/ and use them in postcss.config.js.
40% building 7/8 modules 1 active ...s\sass-loader\dist\cjs.js!C:\Migu\postcss-critical-css-test-master\src\module.scssYou did not set any plugins, parser, or stringifier. Right now, PostCSS does nothing. Pick plugins for your case on https://www.postcss.parts/ and use them in postcss.config.js.

when scss (and css as well) entrypoints are passed to Webpack configuration object. This happens when js entrypoints import css/scss files in which @critical rules are called.

Example:

module.exports = () => {
    return {
        entry: {
            main: path.join(__dirname, 'src', 'main.js'),
            site: path.join(__dirname, 'src', 'site.scss')
        },
        ...
    }
}

In this case, main.js imports main.scss that carries a @critical rule, while site.scss may or may not carry @critical rules (both ways will emit warnings).

Unfortunately I can't transform scss entrypoints into js ones and there's no way of silence warnings even playing with Webpack's stats options.

Thanks

zgreen commented 4 years ago

Thanks for the report, I'll take a look.

timjuedemann commented 4 years ago

I am encountering the same problem when running postcss-critical-css from within a CodeKit hook using postcss-cli.

I am importing scss files which are then compiled to a single css file using CodeKit’s libsass compiler. Said css file then serves as the entrypoint for my PostCSS plugin chain. However, any imported scss file carrying a @critical rule will result in the console warning mentioned by the OP. It’s worth noting that despite the warning everything compiles correctly.