-
Notifications
You must be signed in to change notification settings - Fork 0
/
svelte-native.webpack.config.js
44 lines (41 loc) · 1.65 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
38
39
40
41
42
43
44
const webpackConfig = require("./webpack.config");
const preprocessConfig = require("./svelte.config.js");
const svelteNativePreprocessor = require("svelte-native-preprocessor");
module.exports = env => {
const config = webpackConfig(env);
//stop ns preview from using its own bundled svelte and svelte-native (it is out of date)
config.externals = (config.externals || []).filter(x => !x.source.startsWith('^svelte'));
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
},
onwarn: (warning, onwarn) => {
if (!/A11y:/.test(warning.message)) {
onwarn(warning);
}
}
}
}
]
});
// 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;
};