-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsvelte-native.webpack.config.js
37 lines (34 loc) · 1.27 KB
/
svelte-native.webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const webpackConfig = require("./webpack.config");
const preprocessConfig = require("./svelte.config.js");
const svelteNativePreprocessor = require("svelte-native-preprocessor");
module.exports = env => {
const config = webpackConfig(env);
config.resolve.extensions = [".ts", ".mjs", ".js", ".svelte", ".scss", ".css"];
config.module.rules.push({
test: /\.svelte$/,
exclude: /node_modules/,
use: [
{
loader: 'svelte-loader-hot',
options: {
dev: env.production ? false : true,
preprocess: [preprocessConfig.preprocess, svelteNativePreprocessor()],
hotReload: env.production ? false : true,
hotOptions: {
injectCss: false,
native: true
}
}
}
]
});
// insert the mjs loader after ts-loader
const tsLoaderRule = config.module.rules.find(r => r.use.loader === "ts-loader");
const indexOfTsLoaderRule = config.module.rules.indexOf(tsLoaderRule);
const mjsRule = {
test: /\.mjs$/,
type: 'javascript/auto',
};
config.module.rules.splice(indexOfTsLoaderRule, 0, mjsRule);
return config;
};