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

Exclude node_modules from importing css modules #1

Closed
wants to merge 4 commits into from

Conversation

js62789
Copy link
Contributor

@js62789 js62789 commented May 18, 2017

In the consumer-web project, we're attempting to import a CSS file from node_modules, but the default behavior is to import the file using CSS Modules, which effectively namespaces class names. We had to override the loaders in the import statement and tell ESLint to ignore the behavior. We should assume that a CSS file coming from node_modules should not be namespaced and should be globally applicable.

@js62789 js62789 requested a review from djMax May 18, 2017 15:34
@js62789
Copy link
Contributor Author

js62789 commented May 18, 2017

I just realized I did this wrong, one more commit incoming.

@jasisk
Copy link
Contributor

jasisk commented May 18, 2017

I'm EDIT not /EDIT sure I follow what's going on here.

You have two loaders that are similar (the second being the only one to load the cssnext plugin for postcss). The first has a whitelist but that's a noop since there's no blacklist (i.e., the test will pass for every *.css file). Regardless, both loaders have css modules enabled (modules: true).

@js62789
Copy link
Contributor Author

js62789 commented May 18, 2017

I've restored postcss-next and remove the modules setting.

@@ -107,14 +136,21 @@ export function webpackConfig(env) {

if (isProd) {
// fix loaders for prod
const [, cssLoader] = loaders;
const [, thirdPartyCssLoader, cssLoader] = loaders;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow all this, but where is the third party one split from the regular loader?

@js62789
Copy link
Contributor Author

js62789 commented May 23, 2017

I'm not a big fan of this webpack config because it is hard to follow. The initial commits to this branch added in a separate loader for CSS files that come from the node_modules directory (so that modules:true wasn't set). Because of that, I needed to wrap it with the ExtractTextPlugin the same way that the original CSS loader did. It would be preferable to have something like webpack.config.production.js and webpack.development.js. The redundancy would be worth it IMO.

@djMax
Copy link
Contributor

djMax commented May 23, 2017 via email

@js62789
Copy link
Contributor Author

js62789 commented May 23, 2017

@djMax What do I have to do to get this approved?

@djMax
Copy link
Contributor

djMax commented May 24, 2017

@jasisk is the one to press the button on this one.

@jasisk jasisk self-assigned this May 24, 2017
@jasisk
Copy link
Contributor

jasisk commented May 24, 2017

Will review first thing in the am.

@js62789 js62789 closed this Jun 15, 2017
@js62789 js62789 deleted the jsmith/node-modules-css branch June 15, 2017 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants