Skip to content

Commit c5ddf0a

Browse files
authored
Merge pull request #3 from wjgogogo/master
fix: 修复less loader 不从 node_modules 中寻找样式文件的错误
2 parents d6a2ed6 + 0142fb0 commit c5ddf0a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jest-less-loader",
3-
"version": "0.1.2",
3+
"version": "0.2.0",
44
"description": "Jest transformer for .less file.",
55
"license": "MIT",
66
"main": "lib/index.js",
@@ -19,7 +19,7 @@
1919
},
2020
"dependencies": {},
2121
"peerDependencies": {
22-
"less": "^3.10.3"
22+
"less": "^4.1.3"
2323
},
2424
"keywords": [
2525
"jest",
@@ -37,7 +37,7 @@
3737
"husky": "^3.0.5",
3838
"jest": "^24.9.0",
3939
"jest-electron": "^0.1.7",
40-
"less": "^3.10.3",
40+
"less": "^4.1.3",
4141
"lint-md-cli": "^0.1.1",
4242
"lint-staged": "^9.3.0",
4343
"prettier": "^1.18.2",

src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ function transformLess(fileContent: string, filePath: string): string {
1717
const data = fileContent.replace(/^\uFEFF/, '');
1818

1919
// handle with fileContent include @import url
20-
const options = { sync: true, syncImport: true, relativeUrls: true, filename: filePath };
20+
// paths used for search less file from node_modules, such as `@import '@lib/index.less'`
21+
const options = { sync: true, syncImport: true, relativeUrls: true, filename: filePath, paths: ['node_modules'] };
2122

2223
let css = '';
2324

0 commit comments

Comments
 (0)