Skip to content

Commit 9dd83bb

Browse files
author
Ives van Hoorne
committed
Fix css modules in vue
1 parent 21b995c commit 9dd83bb

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
// @flow
2-
import Core from 'css-modules-loader-core';
32
import { type LoaderContext } from '../../transpiled-module';
43

5-
const core = new Core();
4+
let core = null;
65

7-
export default (code: string, loaderContext: LoaderContext) =>
8-
core
6+
export default async (code: string, loaderContext: LoaderContext) => {
7+
if (!core) {
8+
const Core = await import('css-modules-loader-core');
9+
10+
core = new Core();
11+
}
12+
13+
return core
914
.load(code, loaderContext.path, (dependencyPath: string) => {
1015
const tModule = loaderContext.addDependency(dependencyPath);
1116

@@ -15,3 +20,4 @@ export default (code: string, loaderContext: LoaderContext) =>
1520
css: injectableSource,
1621
exportTokens,
1722
}));
23+
};

src/sandbox/eval/transpilers/vue/loader.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ const getStyleFileName = attrs => {
2121
};
2222

2323
const getStyleLoaders = (attrs, id, scoped) => {
24-
let loader = `!style-loader!vue-style-compiler?${JSON.stringify({
25-
id,
26-
scoped: !!scoped,
27-
})}`;
24+
let loader = `!style-loader`;
2825

2926
if (attrs.module) {
3027
loader += `?${JSON.stringify({ module: true })}`;
3128
}
3229

30+
loader += `!vue-style-compiler?${JSON.stringify({
31+
id,
32+
scoped: !!scoped,
33+
})}`;
34+
3335
if (attrs.lang === 'scss') loader += '!sass-loader';
3436
if (attrs.lang === 'sass') loader += '!sass-loader';
3537
if (attrs.lang === 'styl' || attrs.lang === 'stylus')

0 commit comments

Comments
 (0)