csstools / postcss-normalize

Use the parts of normalize.css (or sanitize.css) you need from your browserslist
Creative Commons Zero v1.0 Universal
816 stars 40 forks source link

How to make it work with webpack postcss-loader? #24

Closed francoisromain closed 6 years ago

francoisromain commented 6 years ago

Hello and thank you for the plugin. I can not get it to work with webpack postcss-loader and postcss-import.

WARNING in ./node_modules/css-loader?{"sourceMap":true,"importLoaders":1}!./node_modules/postcss-loader/lib?{"sourceMap":true}!./src/css/styles.css
(Emitted value instead of an instance of Error) postcss-import: …/src/css/styles.css:9:1: @import must precede all other statements (besides @charset)
ERROR in ./node_modules/css-loader?{"sourceMap":true,"importLoaders":1}!./node_modules/postcss-loader/lib?{"sourceMap":true}!./src/css/styles.css
Module build failed: Error: Failed to find 'postcss-normalize'

What am I doing wrong here? Thank you

suazithustra commented 6 years ago

+1

wesleyboar-fka-iosulfur commented 6 years ago

I had a similar conflict with postcss-import. My solution, for my setup (not webpack), was to ensure that @import-normalize; was called in a file that had no @import statements. A basic example of my solution/setup:

…/src/styles/generic/normalize.css

@import-normalize;

…/src/styles/generic/opinionated.css

@import ('…/…/h5bp.css');
@import ('…/…/base.css');

…/src/omg-all-the-styles.css

…
@import ('…/generic/normalize.css');
@import ('…/generic/opinionated.css');
…
jonathantneal commented 6 years ago

@wesleyboar’s solution should work for you, and also some of the options have changed since this bug was first reported, as you should be able to specify a manual injection point.

While somewhat tangental, I’ve also added Webpack installation instructions: https://github.com/csstools/postcss-normalize/blob/master/INSTALL.md#webpack