-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Best Practices for overriding loader options #756
Comments
@anithri Yes, for now 👍 Perhaps you wanna consider merging options first so you don't override existing options. const { environment } = require('@rails/webpacker')
const merge = require('webpack-merge')
const myCssLoaderOptions = {
modules: true,
sourceMap: true,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
const CSSLoader = environment.loaders.get('style').use.find(el => el.loader === 'css-loader')
CSSLoader.options = merge(CSSLoader.options, myCssLoaderOptions)
module.exports = environment //cc @javan ^^ |
I can see why you'd question updating this loader's options since it requires scanning the |
I overrided SCSS Modules like mentioned above. But it not works. My class looks like https://prnt.sc/jcbnke I use react on rails and webpacker. |
@AntonBerez I ran into this issue as well.. in the end I set it up like this: const { environment } = require('@rails/webpacker');
let sassLoader = environment.loaders.get('moduleSass');
let index = environment.loaders.get('moduleSass').use.findIndex(el => el.loader === 'css-loader');
sassLoader.use[index].options = {
modules: true,
sourceMap: true,
localIdentName: '[name]__[local]___[hash:base64:5]'
};
module.exports = environment; Notice how I used |
I'm brute forcing here because neither moduleSass or moduleCss worked, and by why should I spend time isolating the "right" one? (they all use postcss-loader). 😭 This is mainly because bulma + postcss-cssnext don't play nice. By the way, why can't webpacker use webpack.config.js ? |
my module css was showing up in development, but wasn't compiled into output css files in production. we're using |
I did this to override css-loader with new options. Is this the way it's meant to be done?
The text was updated successfully, but these errors were encountered: