This repository has been archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
71 lines (62 loc) · 1.44 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { rollup } from 'rollup';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import common from '@rollup/plugin-commonjs';
import * as esbuild from 'esbuild';
import webpack from 'webpack';
import { promisify } from 'node:util';
import { resolve } from 'path';
import * as vite from 'vite';
const bundle = await rollup({
input: ['./src/simple.js', './src/solid.js'],
plugins: [
nodeResolve({
preferBuiltins: true,
exportConditions: ['worker', 'solid'],
browser: true,
}),
common(),
],
});
// or write the bundle to disk
await bundle.write({ format: 'esm', dir: './out/rollup' });
// closes the bundle
await bundle.close();
// esbuild
await esbuild.build({
entryPoints: ['./src/simple.js', './src/solid.js'],
bundle: true,
outdir: './out/esbuild',
format: 'esm',
conditions: ['worker', 'browser'],
platform: 'browser',
});
// webpack
const compiler = webpack({
target: 'web',
entry: { simple: './src/simple.js', solid: './src/solid.js' },
output: {
path: resolve('./out/webpack'),
filename: '[name].js',
},
optimization: {
minimize: false,
},
});
await promisify(compiler.run.bind(compiler))();
// vite
await vite.build({
root: resolve('./src'),
build: {
ssr: true,
rollupOptions: {
input: ['./src/simple.js', './src/solid.js'],
output: {
dir: './out/vite',
},
},
},
ssr: {
target: 'webworker',
noExternal: true,
},
});