@@ -10,14 +10,6 @@ const stringifyLoader = require.resolve('./stringifyLoader.js');
10
10
const trailingSlash = / [ / \\ ] $ / ;
11
11
const isLessCompatible = / \. ( l e | c ) s s $ / ;
12
12
13
- // Less automatically adds a .less file extension if no extension was given.
14
- // This is problematic if there is a module request like @import "~some-module";
15
- // because in this case Less will call our file manager with `~some-module.less`.
16
- // Since dots in module names are highly discouraged, we can safely assume that
17
- // this is an error and we need to remove the .less extension again.
18
- // However, we must not match something like @import "~some-module/file.less";
19
- const matchMalformedModuleFilename = / ( ~ [ ^ / \\ ] + ) \. l e s s $ / ;
20
-
21
13
// This somewhat changed in Less 3.x. Now the file name comes without the
22
14
// automatically added extension whereas the extension is passed in as `options.ext`.
23
15
// So, if the file name matches this regexp, we simply ignore the proposed extension.
@@ -43,7 +35,11 @@ function createWebpackLessPlugin(loaderContext) {
43
35
} ) ;
44
36
45
37
class WebpackFileManager extends less . FileManager {
46
- supports ( ) {
38
+ supports ( filename ) {
39
+ if ( this . isPathAbsolute ( filename ) ) {
40
+ return false ;
41
+ }
42
+
47
43
// Our WebpackFileManager handles all the files
48
44
return true ;
49
45
}
@@ -58,15 +54,11 @@ function createWebpackLessPlugin(loaderContext) {
58
54
}
59
55
60
56
getUrl ( filename , options ) {
61
- if ( less . version [ 0 ] >= 3 ) {
62
- if ( options . ext && ! isModuleName . test ( filename ) ) {
63
- return this . tryAppendExtension ( filename , options . ext ) ;
64
- }
65
-
66
- return filename ;
57
+ if ( options . ext && ! isModuleName . test ( filename ) ) {
58
+ return this . tryAppendExtension ( filename , options . ext ) ;
67
59
}
68
60
69
- return filename . replace ( matchMalformedModuleFilename , '$1' ) ;
61
+ return filename ;
70
62
}
71
63
72
64
async loadFile ( filename , currentDirectory , options ) {
@@ -109,7 +101,7 @@ function createWebpackLessPlugin(loaderContext) {
109
101
install ( lessInstance , pluginManager ) {
110
102
pluginManager . addFileManager ( new WebpackFileManager ( ) ) ;
111
103
} ,
112
- minVersion : [ 2 , 1 , 1 ] ,
104
+ minVersion : [ 3 , 0 , 0 ] ,
113
105
} ;
114
106
}
115
107
0 commit comments