This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
53 lines (49 loc) · 1.92 KB
/
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
import path from 'path'
import esbuild from 'esbuild'
import alias from 'esbuild-plugin-alias'
import { wasmLoader } from 'esbuild-plugin-wasm'
const polyfills = alias({
'zlib': path.resolve('./node_modules/browserify-zlib/lib/index.js'),
'stream': path.resolve('./node_modules/stream-browserify/index.js'),
'crypto': path.resolve('./node_modules/crypto-browserify/index.js'),
'http': path.resolve('./node_modules/stream-http/index.js'),
'https': path.resolve('./node_modules/stream-http/index.js'),
'fs': path.resolve('./node_modules/browserify-fs/index.js'),
'buffer': path.resolve('./node_modules/buffer/index.js'),
'events': path.resolve('./node_modules/events/events.js'),
'util': path.resolve('./node_modules/util/util.js'),
'url': path.resolve('./node_modules/url/url.js'),
'assert': path.resolve('./node_modules/assert/build/assert.js'),
'path': path.resolve('./node_modules/path/path.js'),
'os': path.resolve('./node_modules/os-browserify/main.js'),
'tls': path.resolve('./node_modules/node-libs-browser/mock/tls.js'),
'net': path.resolve('./node_modules/node-libs-browser/mock/net.js'),
})
// esbuild.build({
// entryPoints: ['./src/index.ts'],
// outfile: './build/index.js',
// watch: process.argv.includes('-w') || process.argv.includes('--watch'),
// format: 'esm',
// bundle: true,
// publicPath: '/',
// sourcemap: true,
// minify: process.argv.includes('-m') || process.argv.includes('--minify'),
// external: ['./node_modules/*']
// })
esbuild.build({
entryPoints: ['./src/test.ts'],
outfile: './build/test.js',
watch: process.argv.includes('-w') || process.argv.includes('--watch'),
target: "esnext",
format: 'esm',
bundle: true,
publicPath: '/',
sourcemap: true,
minify: process.argv.includes('-m') || process.argv.includes('--minify'),
plugins: [polyfills, wasmLoader()],
define: {
'global': 'globalThis',
'process.platform': '"web"',
'process.env': '{}'
}
})