2022-06-14 23:30:00 +02:00
|
|
|
/* This script will build the package with esbuild */
|
2022-08-24 19:38:57 +02:00
|
|
|
import esbuild from 'esbuild'
|
|
|
|
import pkg from './package.json' assert { type: 'json' }
|
2022-06-14 23:30:00 +02:00
|
|
|
|
|
|
|
// Create banner based on package info
|
|
|
|
const banner = `/**
|
|
|
|
* ${pkg.name} | v${pkg.version}
|
|
|
|
* ${pkg.description}
|
|
|
|
* (c) ${new Date().getFullYear()} ${pkg.author}
|
|
|
|
* @license ${pkg.license}
|
|
|
|
*/`
|
|
|
|
|
|
|
|
// Shared esbuild options
|
|
|
|
const options = {
|
|
|
|
banner: { js: banner },
|
|
|
|
bundle: true,
|
2022-08-28 17:26:29 +02:00
|
|
|
entryPoints: ['src/index.mjs'],
|
2022-08-24 19:38:57 +02:00
|
|
|
format: 'esm',
|
|
|
|
outfile: 'dist/index.mjs',
|
2022-10-13 16:47:49 +02:00
|
|
|
external: ['@freesewing'],
|
2022-06-14 23:30:00 +02:00
|
|
|
metafile: process.env.VERBOSE ? true : false,
|
|
|
|
minify: process.env.NO_MINIFY ? false : true,
|
|
|
|
sourcemap: true,
|
|
|
|
}
|
|
|
|
|
2022-08-24 19:38:57 +02:00
|
|
|
// Let esbuild generate the build
|
2022-10-15 14:33:54 +02:00
|
|
|
const build = async () => {
|
|
|
|
const result = await esbuild.build(options).catch(() => process.exit(1))
|
2022-06-14 23:30:00 +02:00
|
|
|
|
|
|
|
if (process.env.VERBOSE) {
|
|
|
|
const info = await esbuild.analyzeMetafile(result.metafile)
|
|
|
|
console.log(info)
|
|
|
|
}
|
2022-10-15 14:33:54 +02:00
|
|
|
}
|
|
|
|
build()
|