@@ -81,6 +81,7 @@ const cssRegex = /\.css$/;
81
81
const cssModuleRegex = / \. m o d u l e \. c s s $ / ;
82
82
const sassRegex = / \. ( s c s s | s a s s ) $ / ;
83
83
const sassModuleRegex = / \. m o d u l e \. ( s c s s | s a s s ) $ / ;
84
+ const lessRegex = / \. l e s s $ / ;
84
85
85
86
const hasJsxRuntime = ( ( ) => {
86
87
if ( process . env . DISABLE_NEW_JSX_TRANSFORM === 'true' ) {
@@ -115,7 +116,7 @@ module.exports = function (webpackEnv) {
115
116
const shouldUseReactRefresh = env . raw . FAST_REFRESH ;
116
117
117
118
// common function to get style loaders
118
- const getStyleLoaders = ( cssOptions , preProcessor ) => {
119
+ const getStyleLoaders = ( cssOptions , preProcessor , preProcessorOptions = { } ) => {
119
120
const loaders = [
120
121
isEnvDevelopment && require . resolve ( 'style-loader' ) ,
121
122
isEnvProduction && {
@@ -188,6 +189,7 @@ module.exports = function (webpackEnv) {
188
189
{
189
190
loader : require . resolve ( preProcessor ) ,
190
191
options : {
192
+ ...preProcessorOptions ,
191
193
sourceMap : true ,
192
194
} ,
193
195
}
@@ -584,6 +586,35 @@ module.exports = function (webpackEnv) {
584
586
'sass-loader'
585
587
) ,
586
588
} ,
589
+ // Adds support for Less (using .less extensions)
590
+ {
591
+ test : lessRegex ,
592
+ use : getStyleLoaders (
593
+ {
594
+ importLoaders : 3 ,
595
+ sourceMap : isEnvProduction
596
+ ? shouldUseSourceMap
597
+ : isEnvDevelopment ,
598
+ modules : {
599
+ mode : 'icss' ,
600
+ } ,
601
+ } ,
602
+ 'less-loader' ,
603
+ {
604
+ lessOptions : {
605
+ javascriptEnabled : true ,
606
+ modifyVars : {
607
+ '@primary-color' : '#722ed1'
608
+ } ,
609
+ }
610
+ }
611
+ ) ,
612
+ // Don't consider CSS imports dead code even if the
613
+ // containing package claims to have no side effects.
614
+ // Remove this when webpack adds a warning or an error for this.
615
+ // See https://github.com/webpack/webpack/issues/6571
616
+ sideEffects : true ,
617
+ } ,
587
618
// "file" loader makes sure those assets get served by WebpackDevServer.
588
619
// When you `import` an asset, you get its (virtual) filename.
589
620
// In production, they would get copied to the `build` folder.
0 commit comments