How to Customize Razzle.js css-modules options #1496
Answered
by
fivethreeo
majidghafoorzade
asked this question in
Q&A
-
I want to config css-modules in my Razzle app and change "localIdentName" option to only display hash in my class names. This is my razzle.config.js : const makeLoaderFinder = require('razzle-dev-utils/makeLoaderFinder');
module.exports = {
plugins: ['scss'],
modify( config ) {
const cssLoaderFinder = makeLoaderFinder('css-loader');
const cssRule = config.module.rules.find(cssLoaderFinder);
cssRule.use.find(cssLoaderFinder).options.localIdentName = "[hash:base64:5]";
}
}; But it not works! How I can do this? |
Beta Was this translation helpful? Give feedback.
Answered by
fivethreeo
Dec 30, 2020
Replies: 2 comments
-
I resolve it by : 'use strict';
const cloneDeep = require('lodash.clonedeep');
const makeLoaderFinder = require('razzle-dev-utils/makeLoaderFinder');
module.exports = {
modifyWebpackConfig(opts) {
const config = opts.webpackConfig;
const configClone = cloneDeep(config);
const cssLoaderIndex = configClone.module.rules.findIndex(makeLoaderFinder('css-loader'));
if (opts.env.target === 'node') {
config.module.rules[cssLoaderIndex].use[0].options.modules.localIdentName = "[hash:base64:5]";
} else {
config.module.rules[cssLoaderIndex].use[1].options.modules.localIdentName = "[hash:base64:5]";
}
return config;
},
}; Hope it can help you if you have similar problem :) |
Beta Was this translation helpful? Give feedback.
0 replies
-
localIdentName fixed in v3.3.9 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
fivethreeo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
localIdentName fixed in v3.3.9