Open CoderAWei opened 2 years ago
same question!!!help!!! @CoderAWei
I do like this:
configure: webpackConfig => { const loaders = webpackConfig.module.rules.find(rule => Array.isArray(rule.oneOf)).oneOf; loaders.push({ test: /\.less$/, use: ['style-loader', 'css-loader', 'less-loader', { loader: 'style-resources-loader', options: { patterns: [ path.resolve(__dirname, 'src/styles/_variable.less'), ], injector: 'append' } }] }) return webpackConfig }
It doesn't work too!
I want to auto import
less
variables in all files, but fails. Here are my settings:// craco.config.js module.export = { plugins: [ { plugin: styleResourcesLoader, options: { patterns: path.resolve(__dirname, './src/styles/variables.less') } } ] }
It doesn't work! How can I fix it? Thanks!!!!
module.exports = { plugins: [ { plugin: CracoLessPlugin, options: { modifyLessRule: (lessRule) => { console.log(JSON.stringify(lessRule)) lessRule.use.push({ loader: 'style-resources-loader', options: { patterns: path.resolve(__dirname, 'src/styles/_variable.less'), injector: 'append' } }) return lessRule }, lessLoaderOptions: { lessOptions: { javascriptEnabled: true, }, }, }, }, ] }
I want to auto import
less
variables in all files, but fails. Here are my settings:It doesn't work! How can I fix it? Thanks!!!!