2022-04-13 19:08:56 +08:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
const esbuild = require('esbuild');
|
|
|
|
const path = require('path');
|
2023-02-18 06:37:13 +08:00
|
|
|
const fs = require('fs');
|
2022-04-13 19:08:56 +08: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-03 03:11:02 +08:00
|
|
|
const entryPoints = {
|
|
|
|
app: path.join(__dirname, '../../resources/js/app.js'),
|
|
|
|
code: path.join(__dirname, '../../resources/js/code/index.mjs'),
|
2023-04-15 01:08:57 +08:00
|
|
|
'legacy-modes': path.join(__dirname, '../../resources/js/code/legacy-modes.mjs'),
|
2024-04-08 21:41:51 +08:00
|
|
|
markdown: path.join(__dirname, '../../resources/js/markdown/index.mjs'),
|
2024-05-28 06:50:28 +08:00
|
|
|
wysiwyg: path.join(__dirname, '../../resources/js/wysiwyg/index.ts'),
|
2022-08-03 03:11:02 +08:00
|
|
|
};
|
2022-04-13 19:08:56 +08:00
|
|
|
|
|
|
|
// Locate our output directory
|
2022-08-03 03:11:02 +08:00
|
|
|
const outdir = path.join(__dirname, '../../public/dist');
|
2022-04-13 19:08:56 +08:00
|
|
|
|
|
|
|
// Build via esbuild
|
|
|
|
esbuild.build({
|
|
|
|
bundle: true,
|
2023-02-18 06:37:13 +08:00
|
|
|
metafile: true,
|
2022-08-03 03:11:02 +08:00
|
|
|
entryPoints,
|
|
|
|
outdir,
|
2022-04-13 19:08:56 +08:00
|
|
|
sourcemap: true,
|
2023-12-09 18:49:28 +08:00
|
|
|
target: 'es2021',
|
2022-04-13 19:08:56 +08:00
|
|
|
mainFields: ['module', 'main'],
|
|
|
|
format: 'esm',
|
|
|
|
minify: isProd,
|
2023-12-09 18:49:28 +08:00
|
|
|
logLevel: 'info',
|
2024-03-24 06:04:18 +08:00
|
|
|
banner: {
|
|
|
|
js: '// See the "/licenses" URI for full package license details',
|
|
|
|
css: '/* See the "/licenses" URI for full package license details */',
|
|
|
|
},
|
2023-02-18 06:37:13 +08:00
|
|
|
}).then(result => {
|
|
|
|
fs.writeFileSync('esbuild-meta.json', JSON.stringify(result.metafile));
|
2023-12-09 18:49:28 +08:00
|
|
|
}).catch(() => process.exit(1));
|