-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathvite.build.js
85 lines (80 loc) · 1.7 KB
/
vite.build.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
83
84
85
// vite.config.js
import { resolve, dirname } from 'path'
import { build } from 'vite'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import { fileURLToPath } from 'url'
import { appendFile } from 'fs/promises'
const __dirname = dirname(fileURLToPath(import.meta.url))
await build({
configFile: false,
build: {
target: 'esnext',
emptyOutDir: false,
minify: 'esbuild',
lib: {
entry: resolve(__dirname, 'src/jassub.js'),
name: 'JASSUB',
fileName: (format) => `jassub.${format}.js`
}
}
})
await build({
configFile: false,
plugins: [
viteStaticCopy({
targets: [
{
src: 'dist/js/jassub-worker.wasm',
dest: './'
},
{
src: 'dist/js/jassub-worker-modern.wasm',
dest: './'
}
]
})
],
resolve: {
alias: {
wasm: 'dist/js/jassub-worker-modern.js'
}
},
build: {
target: 'esnext',
outDir: './dist',
minify: 'esbuild',
lib: {
fileName: () => 'jassub-worker.js',
entry: 'src/worker.js',
formats: ['cjs']
},
emptyOutDir: false
}
})
await build({
configFile: false,
build: {
terserOptions: {
mangle: false,
compress: false,
format: {
comments: false
}
},
target: 'esnext',
outDir: './dist',
minify: 'terser',
rollupOptions: {
treeshake: false,
output: {
exports: 'none',
entryFileNames: '[name].js'
},
input: {
'jassub-worker.wasm': resolve(__dirname, 'dist/js/jassub-worker.wasm.js')
}
},
emptyOutDir: false
}
})
await appendFile(resolve(__dirname, 'dist/jassub-worker.wasm.js'), 'self.WebAssembly=WebAssembly')