Overriding loader styles in webpack
See original GitHub issueHello,
I’m trying to override webpack configuration so I can add some options on css-loader and postcss-loader. However I run into an issue that says:
./src/components/mycomponent/MyComponent.css
Module build failed: Syntax Error
(5:1) Unknown word
3 | // load the styles
4 | var content = require("!!../../../node_modules/css-loader/index.js?{\"importLoaders\":1,\"modules\":true,\"localIdentName\":\"[name]__[local]___[hash:base64:5]\",\"camelCase\":true}!../../../node_modules/postcss-loader/lib/index.js!./MyComponent.css");
after reading some issues over css-loader. It looks like the issue is that I’m overriding the styles that you already defined on razzle conf (see https://stackoverflow.com/questions/37031123/why-am-i-not-being-able-to-compile-sass-with-webpack) and that doesn’t go well. I guess that’s why Vue created vue-loader.
Given my scenario, should it be best just to fork your project and start from there?
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
style-loader - webpack
Allows to setup absolute path to custom function that allows to override default behavior and insert styles at any position. Warning. Do not...
Read more >Webpack can't fix CSS override issue and bundle <style ...
One solution is to enable local scoped css to avoid styles bleeding/overrides. Update your css-loader options to include modules: true
Read more >css-module-override-webpack-plugin - npm
It loads CSS module overrides according to a file pattern and creates additional stylesheet files.
Read more >Devon Govett on Twitter: "I tried overriding the webpack config ...
I tried overriding the webpack config to add style-loader and css-loader, but then I get a syntax error like it's trying to treat...
Read more >Custom Webpack config | Remotion | Make videos ...
You can override it reducer-style by creating a function that takes the previous Webpack configuration and returns the the new one.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@imjared I’ve been collecting helpers for
razzle.config.jsand putting them in module called razzle-config-utils so I don’t have to write the samefind/findIndexhacks over multiple projects. You can check it out and see if it helps 😃What you’re trying here would be possible with:
BTW, you’re mixing (very?) old webpack 1.x syntax with the new one - css should be css-loader and you should no longer specify your configuration as
?query&stringbut useoptionsinstead.@jaredpalmer oh yeah, it’d be perfect 😃 I was actually planning to release this config (probably tomorrow) with some tweaks and configurability as npm package so it can be used in a simliar fashion to
my-razzle-modifictionsfrom README 😃