Skip to content

Commit

Permalink
🚀 esbuild system
Browse files Browse the repository at this point in the history
this removes the watch command
but build speeds
  • Loading branch information
e9x committed Jul 6, 2023
1 parent 130ba38 commit 8549cfd
Show file tree
Hide file tree
Showing 3 changed files with 1,225 additions and 2,713 deletions.
35 changes: 35 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { rimraf } from 'rimraf';
import { copyFile, mkdir, readFile } from 'node:fs/promises';
import { build } from 'esbuild';

// read version from package.json
const pkg = JSON.parse(await readFile('package.json'));
process.env.ULTRAVIOLET_VERSION = pkg.version;

const isDevelopment = process.argv.includes('--dev');

await rimraf('dist');
await mkdir('dist');

// don't compile these files
await copyFile('src/sw.js', 'dist/sw.js');
await copyFile('src/uv.config.js', 'dist/uv.config.js');

await build({
platform: 'browser',
sourcemap: true,
minify: !isDevelopment,
entryPoints: {
'uv.bundle': './src/rewrite/index.js',
'uv.client': './src/client/index.js',
'uv.handler': './src/uv.handler.js',
'uv.sw': './src/uv.sw.js',
},
define: {
'process.env.ULTRAVIOLET_VERSION': JSON.stringify(
process.env.ULTRAVIOLET_VERSION
),
},
bundle: true,
outdir: 'dist/',
});
Loading

0 comments on commit 8549cfd

Please sign in to comment.