From: Chris Duncan Date: Sat, 11 Jul 2026 07:03:29 +0000 (-0700) Subject: Split build script from configuration. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=bf98c4c543a48f2c81946ca4c4fa936a8655f06b;p=nano-pow.git Split build script from configuration. --- diff --git a/esbuild/build.mjs b/esbuild/build.mjs index 2f8a945..623b3c0 100644 --- a/esbuild/build.mjs +++ b/esbuild/build.mjs @@ -2,53 +2,7 @@ //! SPDX-License-Identifier: GPL-3.0-or-later import { build } from 'esbuild' -import { glsl } from 'esbuild-plugin-glsl' -/** @import { BuildOptions } from 'esbuild' */ - -/** @type BuildOptions */ -const sharedOptions = { - bundle: true, - format: 'esm', - outdir: 'dist', - loader: { - '.d.ts': 'copy', - '.wasm': 'binary' - }, - legalComments: 'inline', - dropLabels: process.env.NODE_ENV === 'development' ? [] : ['LOG'], - sourcemap: 'linked', - plugins: [ - glsl({ - minify: true, - preserveLegalComments: true - }) - ] -} - -/** @type BuildOptions */ -const bundleOptions = { - ...sharedOptions, - platform: 'browser', - target: 'es2022', - entryPoints: [ - './src/index.ts', - './src/utils/index.ts' - ] -} - -/** @type BuildOptions */ -const cliOptions = { - ...sharedOptions, - platform: 'node', - target: 'node22', - bundle: false, - outdir: 'dist/bin', - entryPoints: [ - './src/bin/cli.ts', - './src/bin/server.ts' - ], - packages: 'external' -} +import { bundleOptions, cliOptions } from './config.mjs' await build(bundleOptions) await build(cliOptions) diff --git a/esbuild/config.mjs b/esbuild/config.mjs new file mode 100644 index 0000000..42dea25 --- /dev/null +++ b/esbuild/config.mjs @@ -0,0 +1,50 @@ +//! SPDX-FileCopyrightText: 2025 Chris Duncan +//! SPDX-License-Identifier: GPL-3.0-or-later + +import { glsl } from 'esbuild-plugin-glsl' +/** @import { BuildOptions } from 'esbuild' */ + +/** @type BuildOptions */ +const sharedOptions = { + bundle: true, + format: 'esm', + outdir: 'dist', + loader: { + '.d.ts': 'copy', + '.wasm': 'binary' + }, + legalComments: 'inline', + dropLabels: process.env.NODE_ENV === 'development' ? [] : ['LOG'], + sourcemap: 'linked', + plugins: [ + glsl({ + minify: true, + preserveLegalComments: true + }) + ] +} + +/** @type BuildOptions */ +export const bundleOptions = { + ...sharedOptions, + platform: 'browser', + target: 'es2022', + entryPoints: [ + './src/index.ts', + './src/utils/index.ts' + ] +} + +/** @type BuildOptions */ +export const cliOptions = { + ...sharedOptions, + platform: 'node', + target: 'node22', + bundle: false, + outdir: 'dist/bin', + entryPoints: [ + './src/bin/cli.ts', + './src/bin/server.ts' + ], + packages: 'external' +}