Skip to content

Commit d92f21f

Browse files
authored
Merge pull request #286 from FRSource/fix-external-css-files-src-resolution
fix: external css files src resolution
2 parents 0f450a5 + fe76473 commit d92f21f

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

e2e/__projects__/style/components/External.vue

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
<style module src="./styles/external.css" />
88

9+
<style module="$style2" src="~__styles/external.css" />
10+
911
<style module="css">
1012
.a {
1113
background: color(red a(90%));

e2e/__projects__/style/test.js

+1
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@ test('process External', () => {
4545
const wrapper = mount(External)
4646
expect(wrapper.vm).toBeTruthy()
4747
expect(wrapper.vm.$style.testClass).toEqual('testClass')
48+
expect(wrapper.vm.$style2.testClass).toEqual('testClass')
4849
expect(wrapper.vm.css.a).toEqual('a')
4950
})

lib/process-style.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,14 @@ module.exports = function processStyle(stylePart, filePath, config = {}) {
5353
const vueJestConfig = getVueJestConfig(config)
5454

5555
if (stylePart.src && !stylePart.content) {
56-
stylePart.content = loadSrc(stylePart.src, filePath)
56+
const cssFilePath = applyModuleNameMapper(
57+
stylePart.src,
58+
filePath,
59+
config,
60+
stylePart.lang
61+
)
62+
stylePart.content = loadSrc(cssFilePath, filePath)
63+
filePath = cssFilePath
5764
}
5865

5966
if (vueJestConfig.experimentalCSSCompile === false || !stylePart.content) {

0 commit comments

Comments
 (0)