2022-04-13 07:08:56 -04:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
const esbuild = require('esbuild');
|
|
|
|
const path = require('path');
|
2023-02-17 17:37:13 -05:00
|
|
|
const fs = require('fs');
|
2022-04-13 07:08:56 -04:00
|
|
|
|
|
|
|
// Check if we're building for production
|
|
|
|
// (Set via passing `production` as first argument)
|
|
|
|
const isProd = process.argv[2] === 'production';
|
|
|
|
|
|
|
|
// Gather our input files
|
2022-08-02 15:11:02 -04:00
|
|
|
const entryPoints = {
|
|
|
|
app: path.join(__dirname, '../../resources/js/app.js'),
|
|
|
|
code: path.join(__dirname, '../../resources/js/code/index.mjs'),
|
2023-04-14 13:08:57 -04:00
|
|
|
'legacy-modes': path.join(__dirname, '../../resources/js/code/legacy-modes.mjs'),
|
2022-08-02 15:11:02 -04:00
|
|
|
};
|
2022-04-13 07:08:56 -04:00
|
|
|
|
|
|
|
// Locate our output directory
|
2022-08-02 15:11:02 -04:00
|
|
|
const outdir = path.join(__dirname, '../../public/dist');
|
2022-04-13 07:08:56 -04:00
|
|
|
|
|
|
|
// Build via esbuild
|
|
|
|
esbuild.build({
|
|
|
|
bundle: true,
|
2023-02-17 17:37:13 -05:00
|
|
|
metafile: true,
|
2022-08-02 15:11:02 -04:00
|
|
|
entryPoints,
|
|
|
|
outdir,
|
2022-04-13 07:08:56 -04:00
|
|
|
sourcemap: true,
|
2023-12-09 05:49:28 -05:00
|
|
|
target: 'es2021',
|
2022-04-13 07:08:56 -04:00
|
|
|
mainFields: ['module', 'main'],
|
|
|
|
format: 'esm',
|
|
|
|
minify: isProd,
|
2023-12-09 05:49:28 -05:00
|
|
|
logLevel: 'info',
|
2024-03-23 18:04:18 -04:00
|
|
|
banner: {
|
|
|
|
js: '// See the "/licenses" URI for full package license details',
|
|
|
|
css: '/* See the "/licenses" URI for full package license details */',
|
|
|
|
},
|
2023-02-17 17:37:13 -05:00
|
|
|
}).then(result => {
|
|
|
|
fs.writeFileSync('esbuild-meta.json', JSON.stringify(result.metafile));
|
2023-12-09 05:49:28 -05:00
|
|
|
}).catch(() => process.exit(1));
|