Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ForceImport works wrong #44

Open
Yegorich555 opened this issue Jul 19, 2019 · 1 comment
Open

ForceImport works wrong #44

Yegorich555 opened this issue Jul 19, 2019 · 1 comment

Comments

@Yegorich555
Copy link

How To Reproduce:

  1. create a basic project with webpack 4 and postcss
  2. for postcss-normalize set forceImport: true option
  3. in entry file add several imports "[someName].css"
  4. build project
    https://github.com/Yegorich555/FromScratch_React/tree/postcss-forceImport-bug - for this link use npm run build-dev;
  5. look into main.css file

Actual behavior

We have postcssNormalize result as many as we have css imports in main.js
https://www.screencast.com/t/uBP6hZegP

Expected behavior

forceImport should inject normalize-result once independently on the number of css imports into main.js. Also, this reason why it also doesn't work with *.vue files since ones have several css import (scoped and global)

@brimarq
Copy link

brimarq commented Oct 23, 2019

I'm having the same issue with a basic HTML/CSS/JS project in Webpack 4.41.2 using postcss-normilize plugin with { allowDuplicates: false, forceImport: true } in postcss-loader , then css-loader and style-loader. I have three css imports in my entry js file resulting in three <style> tags in <head>, each one prepended with the normalize css. I get the same result if I move two of the imports into my main css file with @import.

FWIW, I also tried using the style-loader { injectType: 'singletonStyleTag' } option and normalize css is repeated three times in a single <style> tag.

It seems like the only workaround for those of us with multiple css imports is to import normalize.css once, either in our entry js or main css files, but we don't need this plugin to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants