-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathindex.js
50 lines (45 loc) · 1.28 KB
/
index.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
45
46
47
48
49
50
const { join } = require('path');
const preprocess = require('svelte-preprocess')();
exports.webpack = function (config, env, opts) {
config.resolve.extensions.push('.html', '.svelte');
if (config.resolve.mainFields) {
config.resolve.mainFields.unshift('svelte');
} else {
config.resolve.mainFields = ['svelte', 'browser', 'module', 'main'];
}
// disable CSS modules
opts.css.modules = false;
// turn off "raw-loader" on *.html files
config.module.rules.forEach(obj => {
if (obj.test.test('index.html')) {
let rgx, arr=obj.test.toString().match(/\((.*)\)/);
if (arr && arr[1]) {
rgx = arr[1].split('|').filter(x => x !== 'html').join('|');
obj.test = new RegExp('\\.(' + rgx + ')$');
}
}
});
config.module.rules.push({
test: /\.(html|svelte)$/,
exclude: [
// Ignore root template (eg src/index.html)
join(config.context, 'index.html')
],
use: {
loader: 'svelte-loader',
options: {
preprocess,
/**
* TODO:
* - The `url(~@assets/link.svg)`should not need "~" prefix
* - The `hotReload` option does not work in the slightest
* ~> One of many errors: https://github.com/sveltejs/svelte-loader/issues/74
*/
emitCss: true,
hotReload: false,
// hotReload: true, // TODO
hydratable: true
}
}
});
}