-
Notifications
You must be signed in to change notification settings - Fork 3
/
esbuild.js
67 lines (62 loc) · 1.34 KB
/
esbuild.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { build } from 'esbuild';
import { derver } from 'derver';
import svelte from 'esbuild-svelte';
import preprocess from 'svelte-preprocess';
import { eslintPlugin } from 'esbuild-plugin-eslinter';
import copy from './copy.js';
import html from './html.js';
const DEV = process.argv.includes('--dev');
build({
bundle: true,
entryPoints: ['src/main.ts'],
outfile: 'dist/build/bundle.js',
write: DEV,
minify: !DEV,
incremental: DEV,
sourcemap: DEV && 'inline',
loader: { '.png': 'dataurl' },
legalComments: 'none',
logLevel: 'debug',
mainFields: [
'svelte',
'browser',
'module',
'main'
],
plugins: [
svelte({
compileOptions: {
dev: DEV,
css: false,
immutable: true,
legacy: false
},
preprocess: [
preprocess({
sourceMap: DEV,
typescript: true,
scss: {
quietDeps: true,
renderSync: true,
}
})
]
}),
eslintPlugin(),
copy({ from: './src/assets/logo.svg', to: '../logo.svg' }),
html({ in: 'src/index.html', out: 'dist/index.html', dev: DEV }),
]
}).then(bundle => {
DEV && derver({
dir: 'dist',
host: 'localhost',
port: 5555,
watch: ['dist', 'src'],
onwatch: async (lr, item) => {
if (item == 'src') {
lr.prevent();
bundle.rebuild().catch(err => lr.error(err.message, 'Svelte compile error'));
}
}
});
}).catch(e => console.log(e.errors));