current position:Home>Configuration of using less in react project

Configuration of using less in react project

2022-04-29 06:21:55Tool man of konjaku

First , find webpack.config.js file
Usually in node_modules/react-script/webpack.config.js
1.
find
 Insert picture description here
increase

const lessRegex = /\.less$/;                             // less  To configure 
const lessModuleRegex = /\.module\.less$/;   

2. find
 Insert picture description here

{
    
	loader: require.resolve('less-loader')
},

3. find
 Insert picture description here
increase less To configure

// Less  To configure 
{
    
	test: lessRegex,
	exclude: lessModuleRegex,
	use: getStyleLoaders(
		{
    
			importLoaders: 2,
			sourceMap: isEnvProduction && shouldUseSourceMap
		},
		'less-loader'
	),
	sideEffects: true
},

{
    
	test: lessModuleRegex,
	use: getStyleLoaders(
		{
    
			importLoaders: 2,
			sourceMap: isEnvProduction && shouldUseSourceMap,
			modules: true,
			getLocalIdent: getCSSModuleLocalIdent
		},
		'less-loader'
	)
},

copyright notice
author[Tool man of konjaku],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/116/202204260949129721.html

Random recommended