mirror of
https://github.com/titaniumnetwork-dev/Ultraviolet.git
synced 2025-05-13 03:50:01 -04:00
37 lines
1,006 B
JavaScript
37 lines
1,006 B
JavaScript
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,
|
|
treeShaking: true,
|
|
logLevel: 'info',
|
|
outdir: 'dist/',
|
|
});
|