-
-
Notifications
You must be signed in to change notification settings - Fork 384
Ordering issue when @import both less and css #690
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
Comments
Please read how Original: @import './first.less';
@import './second.css'; After /* Because `less` keep `@import` on CSS files as is */
@import './second.css';
/* first.less */ After /* second.css */
/* first.css */ same logic for |
Doh. This is pretty non-intuitive. After all, css imports in the correct order when using a module:
Would be nice to get a warning about this, but alas - that's not your responsibility! Thanks for the confirmation :) For anyone else that comes across this, the workarounds as I see them are:
While both of the second options work to arrange the output CSS correctly in this small repo, just be careful using them as there are some gotchyas explained in various comments on this SO question. |
@ajbeaven We can improve docs for |
I think that'd be worthwhile. It's hard to know what repo it should go in since it's not immediately obvious to anyone that doesn't have deep knowledge of how these loaders and webpack plugins interact when it comes to imports in particular. While I doubt I would have come across something like this when searching for solutions to this problem, at least it'll be somewhere you can link to in future. Probably makes sense under this heading. Feel free to use what I wrote above if you agree with those workarounds. |
@ajbeaven Yep, to be honestly I don't think it is the problem related to webpack/webpack plugins/webpack loaders, I think using other bundlers/tools you faced with the same problem. |
Description
It appears that when both CSS and LESS files are imported using @import, the order is ignored and the CSS always appears first. If I rename first.less to first.css (or second.css to second.less), the output is as expected.
Expected Behavior
dist/main.css:
Actual Behavior
dist/main.css:
Code
webpack.config.js
src/index.js
src/index.less
src/first.less
/* first.less */
src/second.css
/* second.css */
How Do We Reproduce?
npm i
npm run build
dist/main.css
and note the order of the comments in the rendered outputRelated issues
The last comments on #184 mentions this problem, but I didn't see anyone created a new issue.
The text was updated successfully, but these errors were encountered: