-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathesbuild.js
36 lines (35 loc) · 1.02 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
import { build } from 'esbuild'
import { join } from 'path'
import { readdirSync } from 'fs'
import ncp from 'ncp'
const entryPoints = ['index.js', 'edit.js', 'service-worker.js']
readdirSync('./src', { recursive: true }).forEach((file) => {
if (file.endsWith('.js')) {
entryPoints.push(`src/${file}`)
}
})
build({
entryPoints: entryPoints,
format: 'esm',
bundle: true,
minify: true,
sourcemap: !process.env.NODE_ENV,
outdir: join(process.cwd(), 'dist'),
treeShaking: true,
define: {
CACHE_NAME: '"cranes-cache-v1"',
},
})
.then(() =>
Promise.all([
ncp('index.html', 'dist/index.html'),
ncp('index.css', 'dist/index.css'),
ncp('edit.html', 'dist/edit.html'),
ncp('edit.css', 'dist/edit.css'),
ncp('favicon.ico', 'dist/favicon.ico'),
ncp('images', 'dist/images'),
ncp('shaders', 'dist/shaders'),
ncp('codicon.ttf', 'dist/codicon.ttf'),
]),
)
.catch(console.error)