postcss-normalize icon indicating copy to clipboard operation
postcss-normalize copied to clipboard

@import-normalize "opinionated.css"; doesn't actually work

Open marcofugaro opened this issue 5 years ago • 9 comments

Hey, I've tried in my css

@import-normalize "opinionated.css";

However, it is not recognized, and the output remains

@import-normalize "opinionated.css";

This should be supported since it's in the README and also a test is needed for this feature.

marcofugaro avatar May 14 '20 10:05 marcofugaro

It doesn't seem to be working with Create React App (3.4.1) either:

image

ghost avatar May 16 '20 14:05 ghost

This one issue basically makes this otherwise really cool tool completely impossible to use in most modern day projects :(

Dan503 avatar Aug 26 '20 11:08 Dan503

@Dan503 in the meantime, you can import it like this:

@import 'normalize/opinionated';

and have the import plugin ignore that line:

postcssImport({
  filter(importPath) {
    return !importPath.includes('normalize')
  },
}),

marcofugaro avatar Aug 26 '20 13:08 marcofugaro

My problem is that Sass tries to import a file that doesn't exist.

And i tried using a basic css file instead of an scss file but I'm using a Gatsby project and I think Gatsby tries to bundle all the CSS up into one thing so when i tried to add the import statement it complained about not being able to find the file.

Dan503 avatar Aug 26 '20 13:08 Dan503

@Dan503 you have to tell Sass to ignore that import, don't know if there is a way though.

marcofugaro avatar Aug 26 '20 13:08 marcofugaro

I was able to get around Sass by importing a plain .css file. Sass doesn't try to do anything with plain css files.

I still had a problem though because Gatsby still tried to import the css before compiling.

It doesn't add that much bloat so I'm just importing the whole file and not using postcss-normalize.

Dan503 avatar Aug 26 '20 13:08 Dan503

I’m interested in knowing the cause of this.

The entire point of this library is so that exactly your kind of usage should work.

jonathantneal avatar Aug 26 '20 15:08 jonathantneal

Here's a minimum reproduction:

https://github.com/adamwathan/postcss-normalize-bug

@import-normalize "opinionated.css"; is just ignored. Going to see if I can fix as I'd like to move Tailwind to this but we need to be able to do it without having to explain to people the tweaks they need to make to any of their postcss-import configuration or we're going to get a lot of issues.

adamwathan avatar Oct 09 '20 12:10 adamwathan

Okay so after a bit of source-diving, you can make this work currently using the following syntax:

@import-normalize "normalize/opinionated.css";

Perhaps we just need to update the README here and not any actual code?

adamwathan avatar Oct 09 '20 12:10 adamwathan

README updated and added test coverage for @import-normalize "normalize/opinionated.css";.

Thank you everyone

romainmenke avatar Sep 07 '24 16:09 romainmenke