@@ -7,29 +7,25 @@ const getCustomTransformer = require('./utils').getCustomTransformer
7
7
const logResultErrors = require ( './utils' ) . logResultErrors
8
8
const loadSrc = require ( './utils' ) . loadSrc
9
9
10
- function getGlobalResources ( resources , lang , filePath ) {
10
+ function getGlobalResources ( resources , lang ) {
11
11
let globalResources = ''
12
12
if ( resources && resources [ lang ] ) {
13
13
globalResources = resources [ lang ]
14
14
. map ( resource => {
15
- const relativePath = path . relative (
16
- path . dirname ( filePath ) ,
17
- path . resolve ( process . cwd ( ) , resource )
18
- )
19
- return `${ getImportLine ( lang , relativePath ) } \n`
15
+ const absolutePath = path . resolve ( process . cwd ( ) , resource )
16
+ return `${ getImportLine ( lang , absolutePath ) } \n`
20
17
} )
21
18
. join ( '' )
22
19
}
23
20
return globalResources
24
21
}
25
22
26
23
function getImportLine ( lang , filePath ) {
27
- const placeholder = '__PATH__'
28
- const formats = {
29
- default : `@import "${ placeholder } ";` ,
30
- sass : `@import "${ placeholder } "`
24
+ const importLines = {
25
+ default : `@import "${ filePath } ";` ,
26
+ sass : `@import "${ filePath } "`
31
27
}
32
- return ( formats [ lang ] || formats . default ) . replace ( placeholder , filePath )
28
+ return importLines [ lang ] || importLines . default
33
29
}
34
30
35
31
function extractClassMap ( cssCode ) {
@@ -80,7 +76,7 @@ module.exports = function processStyle(stylePart, filePath, config = {}) {
80
76
}
81
77
82
78
let content =
83
- getGlobalResources ( vueJestConfig . resources , stylePart . lang , filePath ) +
79
+ getGlobalResources ( vueJestConfig . resources , stylePart . lang ) +
84
80
stylePart . content
85
81
86
82
const transformer =
0 commit comments