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

All imports after some others CSS declaration should warn and be skipped. #176

Closed
cedeber opened this issue Feb 22, 2016 · 7 comments
Closed
Labels

Comments

@cedeber
Copy link

cedeber commented Feb 22, 2016

Everything worked on v7. Since v8 it doesn't work anymore.

@charset "utf-8";

:root {
    --fontFamily: 'Lato', sans-serif;
    --fontSize: 15px;
    /* ... */
}

@custom-media --medium-screen (width <= 1080px);
@custom-media --small-screen (width <= 580px);
@custom-media --tiny-screen (width <= 320px);

@import url(config/reset.css);
@import url(config/fonts.css);
@import url(config/default.css);
@import url(config/layout.css);
@import url(config/icons.css);

results to:

@charset "utf-8";
:root {}

@import url(config/reset.css);

/* ... */
/* the next files are all imported correctly */

Source files: https://github.com/Frontools/web-starter-kit/tree/master/source/styles
The build.js script is launched thanks to node scripts in https://github.com/Frontools/web-starter-kit/blob/master/package.json

@MoOx
Copy link
Contributor

MoOx commented Feb 22, 2016

Per CSS specifications, import should be at top of a file.

Just move your definitions or root and custom media after import. You are in C(ascading)SS, not in a programming language. custom media and custom props can be defined after a usage, no problem.

All import should warn and be skipped, not just the first poke @TrySound.

@MoOx MoOx added the bug label Feb 22, 2016
@MoOx MoOx changed the title first import rule is not imported since v8 All imports after some others CSS declaration should warn and be skipped. Feb 22, 2016
@cedeber
Copy link
Author

cedeber commented Feb 22, 2016

It's true for CSS specifications, but it is not the case here, before parsing.
It's written in the title: "PostCSS plugin to inline import rules content", which means the resulting CSS will be completely valid as I won't have any imports after the parsing anymore.

Following the specifications is very good, but having a bit of flexibility, like here, too ;)

@MoOx
Copy link
Contributor

MoOx commented Feb 22, 2016

You do not benefit of anything by defining some rules before. The opposite: if an import define it own value, you will not have yours defined.
You can still move that in another import.

@cedeber
Copy link
Author

cedeber commented Feb 22, 2016

Yeah, you're right :)

@LPGhatguy
Copy link

What about imports nested inside rules, which is valid in cases like Sass, and with PostCSS (with postcss-nested)?

I don't see any reason to have this restriction in the plugin; we are not in CSS, we are in a superset of CSS.

@TrySound
Copy link
Member

@LPGhatguy postcss-import never supported nested imports, and never will. We would like to follow spec in most cases.

@RyanZim
Copy link
Collaborator

RyanZim commented Nov 8, 2016

@MoOx PR done: #240

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

No branches or pull requests

5 participants