2022-04-13 13:08:56 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
const esbuild = require('esbuild');
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
// 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 21:11:02 +02:00
|
|
|
const entryPoints = {
|
|
|
|
app: path.join(__dirname, '../../resources/js/app.js'),
|
|
|
|
code: path.join(__dirname, '../../resources/js/code/index.mjs'),
|
|
|
|
};
|
2022-04-13 13:08:56 +02:00
|
|
|
|
|
|
|
// Locate our output directory
|
2022-08-02 21:11:02 +02:00
|
|
|
const outdir = path.join(__dirname, '../../public/dist');
|
2022-04-13 13:08:56 +02:00
|
|
|
|
|
|
|
// Build via esbuild
|
|
|
|
esbuild.build({
|
|
|
|
bundle: true,
|
2022-08-02 21:11:02 +02:00
|
|
|
entryPoints,
|
|
|
|
outdir,
|
2022-04-13 13:08:56 +02:00
|
|
|
sourcemap: true,
|
|
|
|
target: 'es2020',
|
|
|
|
mainFields: ['module', 'main'],
|
|
|
|
format: 'esm',
|
|
|
|
minify: isProd,
|
|
|
|
logLevel: "info",
|
|
|
|
}).catch(() => process.exit(1));
|