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

normalize disapears after second compilation #34

Closed joelmoss closed 5 years ago

joelmoss commented 5 years ago

I've included this lib and the first time webpack builds, normalize is included fine, but after a second compile (after a css change somewhere else), normalize is no longer imported.

@import-normalize;

Any ideas?

diverent2 commented 5 years ago

Can you share the webpack- and postcss-config file you´ve used that lead to this issue? Are you using the forceoption?

postcssNormalize({
  forceImport: true
});
germn commented 5 years ago

I can confirm problem at least for recompile with webpack-dev-server.

Example config can be found here.

To reproduce:

Issue appears regardless of using forceImport.

macdaddyaz commented 5 years ago

I am experiencing the same behavior running through the PostCSS Express middleware.

app.js:

app.use('/css/:style.css', postcssMiddleware({
  src(req) {
    const filename = req.params.style;
    return path.join(__dirname, 'public/stylesheets', `${filename}.pcss`);
  },
  plugins: [
    postcssNormalize({ browsers: 'last 2 versions' }),
  ],
}));

styles.pcss:

@import-normalize;

/* My custom rules */

First request to http://localhost:3000/css/styles.css has the normalize.css rules before the custom rules. Subsequent requests do not (regardless of whether the source has changed).

jonathantneal commented 5 years ago

I think this will be better handled in the next release, when I am more conservatively attaching normalize.css.

jonathantneal commented 5 years ago

Resolved in v8 😄