This repository has been archived by the owner on Dec 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
esbuild.js
82 lines (78 loc) · 1.96 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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 prepare from './prepare.js';
import copy from './copy.js';
import html from './html.js';
const DEV = process.argv.includes('--dev');
prepare().then(() => {
build({
bundle: true,
entryPoints: ['src/main.ts'],
outfile: 'dist/build/bundle.js',
write: DEV,
minify: !DEV,
incremental: DEV,
sourcemap: DEV && 'inline',
loader: { '.png': 'dataurl' },
loader: { '.svg': 'text' },
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: {
prependData: `
$primary-color: #5755d9 !default;
$secondary-color: lighten($primary-color, 37.5%) !default;
$dark-color: #303742 !default;
$gray-color: lighten($dark-color, 55%) !default;
$gray-color-dark: darken($gray-color, 30%) !default;
$gray-color-light: lighten($gray-color, 20%) !default;
$highlight-color: #ffe9b3 !default;
$dark-secondary: #343a51;
`,
quietDeps: true, // dismiss version 2.0 warning
renderSync: true // improve perfomance
},
})
]
}),
eslintPlugin(),
copy([
{ from: './src/assets/img/', to: '../assets/img' },
]),
html({ in: 'src/index.html', out: 'dist/index.html', dev: DEV }),
]
}).then(bundle => {
DEV && derver({
dir: 'dist',
host: 'localhost',
port: 5556,
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));
});