-
-
Notifications
You must be signed in to change notification settings - Fork 607
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
Flag to disable local scoping. #193
Comments
I believe the intention is for the developer to use |
Indeed, and you can wrap multiple selectors in a |
What if you are importing css from an installed node module? Are we meant On Thu, Jan 7, 2016 at 2:12 PM Jop de Klein notifications@github.com
|
That is exactly a question I'm having to: We have a set of react components in our company which are not using css-modules. Right now it is not possible to use the components in a team which wants to use CSS-Modules because it breaks everything... |
A better option may be to simply remove |
You can use different loaders for different CSS files. If you want to use CSS Modules alongside legacy global CSS, a useful technique I've seen in the wild is to name your CSS Modules files with |
^ loaders: [{
exclude: /src\/style/,
include: /src/,
loader: 'style!css?module&importLoaders=2!postcss!sass',
test: /\.scss$/
}, {
include: /src\/style/,
loader: 'style!css?importLoaders=2!postcss!sass',
test: /\.scss$/
}] Inside |
@snaptopixel and @jopdeklein: am I right to assume Just for future reference, both of the following also work fine in an Angular 2 component, to not scope the result, like to allow it to affect
|
@mattmarcello Sorry I missed your question. If you're dealing with external files you should indeed be able to send them through a different set of loaders (via |
@avbentem We are referring to |
Funny you resurrected this @avbentem I was just working on a config for this... In my case, I have two loaders and use the convention @markdalgleish mentioned. The regex was a little tricky to get right but it saves you from having to worry about include/exclude. With these loaders you can load scss|css files from all over the place and only files denoted var cssPrefix = 'css?-mergeRules&importLoaders=2';
var cssModulesPrefix = cssPrefix + '&modules&localIdentName=[local]-[hash:8]';
var cssPostfix = '!postcss!sass';
sassLoader = {
test: /^((?!\.local).)*\.s?css$/,
loader: base.extractSass.extract('style!raw', cssPrefix + cssPostfix)
},
sassModuleLoader = {
test: /\.local\.s?css$/,
loader: base.extractSass.extract('style!raw', cssModulesPrefix + cssPostfix)
} |
So, that's Again just for future reference, for those like me who are trying to make Angular 2 not add scope to imported CSS: something like the following does NOT stop Angular 2 from scoping the result. (Yes, I know nobody claimed it would, and Angular 2's scoping seems to be unrelated here.)
But any of the following would:
...or specific to Angular 2:
|
@avbentem - You can't use You are also trying to pull globals into a component, defeating the purpose of the whole component thing and by extension, the frameworks architecture. |
That doesn't seem to be the case.
class1 and class2 are processed as local
is illegal
is just an evil plot to make life as hard as possible |
I am using css-loader with modules enabled in my webpack.config. I am very much into locally scoped css, but wish to have the ability to turn off css-modules for certain stylesheets (e.g. bootstrap.css).
I am currently accomplishing this by bypassing the loader configuration as follows:
This will insert the stylesheet in a style tag in the head of my markup. This is all well and good, except the stylesheets are not extracted by the ExtractTextPlugin during my production builds.
Any thoughts on this?
Best,
Matt
The text was updated successfully, but these errors were encountered: