Comments (9)
@pastelsky you can also repeat selectors to increase specificity, i.e. .selector.selector.selector
from style-loader.
I hope I can avoid this. You can enforce the order with the @import
statement.
If you want to override bootstrap styles, @import "bootstrap"
at the top of your file. This way the correct order is enforced.
from style-loader.
Umm, If I add multiple @import
statements to each component, it only includes it several times. I need to have my global styles as top, other orders I don't care.
from style-loader.
@forivall @Ciantic Personally, I think relying on order is a poor and fragile practice - which thus should be avoided. What if you shuffle styles during refactoring? What if you use optimizations such as https://github.com/ben-eb/postcss-merge-idents, https://github.com/ben-eb/postcss-merge-rules and https://github.com/hail2u/node-css-mqpacker ? What if you need to append stylesheets lazily to the dom?
I advice using CSS specificity to override rules instead of relying on a fragile convention. CSS preprocessors (Sass/Less/PostCSS) make it trivial.
from style-loader.
Yes, I had an error, I did my importing in wrong place!
E.g.
import * as React from "react";
import * as ReactDom from "react-dom";
import { Provider } from "react-redux";
import { store, history } from "./State";
// ...
import "./GlobalStyles.scss";
when it should be:
import "./GlobalStyles.scss";
import * as React from "react";
import * as ReactDom from "react-dom";
import { Provider } from "react-redux";
import { store, history } from "./State";
// ...
So my problem was simply fixed by moving the importing of scss in top.
from style-loader.
Closing because it's possible to do this yourself by changing the import order.
from style-loader.
Changing the import order wouldn't help in the case where modules are lazy loaded. A module which is loaded later will insert the style tag below the last one, and override all the styles.
This is more of a problem in development, since in production one usually uses ExtractTextPlugin to concatenate css files in proper order. Using ExtractTextPlugin
isn't an option in development mode without losing out on a lot of good stuff.
from style-loader.
@pastelsky I was curious if you found a solution to specify an order for imports. I would essentially like to have certain 3rd party imports be placed at the top, then followed by my application specific imports.
from style-loader.
I'm afraid not @jgornick . In my case, it was just a couple of rules that were not playing well, and I added a !important
rule to force them to apply.
This is obviously not a viable solution if you have more rules, plus such workarounds also go into production.
from style-loader.
Related Issues (20)
- Style-loader duplicates insert function HOT 3
- HMR does not work with webpack 5 HOT 3
- Changes to `insert` module file do not trigger cache invalidation HOT 4
- i can't download the module HOT 1
- HMR does not work HOT 1
- What style-loaders expects as input? HOT 5
- Is there a injectType=lazyStyleTag .use() & .unuse() equivalent when using css-loader + mini-css-extract-plugin HOT 11
- Add support for using lazyStyleTag use() from a JavaScript module (injecting into multiple shadow DOMs) HOT 21
- why style-loader is pitch loader? HOT 2
- Support asset-modules instead of file-loader HOT 3
- Webpack "lazyStyleTag" configuration won't copy fonts after upgrade to Angular 13 HOT 18
- Noop in environment without DOM api HOT 1
- Can not export selectors from `@import url(...)` HOT 2
- Get CSS properties / variables from JavaScript HOT 3
- Vulnerable dependencies (indirect security issues) HOT 1
- webpack 5 is returning a object instead URL HOT 2
- Promotion of unsafe code HOT 1
- Excessive whitespace and line breaks in code generated by style-loader HOT 1
- loaderContext.utils is "undefined", Causes a report that the "contextify" attribute cannot be read from "undefined". HOT 10
- CSS Module is not working. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from style-loader.