Clean build flags
This commit is contained in:
parent
238ba48fb2
commit
4ba586fbe8
|
@ -15,11 +15,7 @@ const { nodeExternalsPlugin } = require("esbuild-node-externals")
|
||||||
|
|
||||||
var argv = require("minimist")(process.argv.slice(2))
|
var argv = require("minimist")(process.argv.slice(2))
|
||||||
|
|
||||||
function runBuild(
|
function runBuild(entry, outfile) {
|
||||||
entry,
|
|
||||||
outfile,
|
|
||||||
opts = { skipMeta: false, bundle: true, silent: false }
|
|
||||||
) {
|
|
||||||
const isDev = process.env.NODE_ENV !== "production"
|
const isDev = process.env.NODE_ENV !== "production"
|
||||||
const tsconfig = argv["p"] || `tsconfig.build.json`
|
const tsconfig = argv["p"] || `tsconfig.build.json`
|
||||||
const tsconfigPathPluginContent = JSON.parse(
|
const tsconfigPathPluginContent = JSON.parse(
|
||||||
|
@ -40,16 +36,12 @@ function runBuild(
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const metafile = !opts.skipMeta
|
|
||||||
const { bundle } = opts
|
|
||||||
|
|
||||||
const sharedConfig = {
|
const sharedConfig = {
|
||||||
entryPoints: [entry],
|
entryPoints: [entry],
|
||||||
bundle,
|
bundle: true,
|
||||||
minify: !isDev,
|
minify: !isDev,
|
||||||
sourcemap: isDev,
|
sourcemap: isDev,
|
||||||
tsconfig,
|
tsconfig,
|
||||||
format: opts?.forcedFormat,
|
|
||||||
plugins: [
|
plugins: [
|
||||||
TsconfigPathsPlugin({ tsconfig: tsconfigPathPluginContent }),
|
TsconfigPathsPlugin({ tsconfig: tsconfigPathPluginContent }),
|
||||||
nodeExternalsPlugin(),
|
nodeExternalsPlugin(),
|
||||||
|
@ -58,10 +50,15 @@ function runBuild(
|
||||||
loader: {
|
loader: {
|
||||||
".svelte": "copy",
|
".svelte": "copy",
|
||||||
},
|
},
|
||||||
metafile,
|
metafile: true,
|
||||||
external: bundle
|
external: [
|
||||||
? ["deasync", "mock-aws-s3", "nock", "pino", "koa-pino-logger", "bull"]
|
"deasync",
|
||||||
: undefined,
|
"mock-aws-s3",
|
||||||
|
"nock",
|
||||||
|
"pino",
|
||||||
|
"koa-pino-logger",
|
||||||
|
"bull",
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
build({
|
build({
|
||||||
|
@ -74,19 +71,16 @@ function runBuild(
|
||||||
fs.copyFileSync(file, `${process.cwd()}/dist/${path.basename(file)}`)
|
fs.copyFileSync(file, `${process.cwd()}/dist/${path.basename(file)}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
!opts.silent &&
|
|
||||||
console.log(
|
console.log(
|
||||||
"\x1b[32m%s\x1b[0m",
|
"\x1b[32m%s\x1b[0m",
|
||||||
`Build successfully in ${(Date.now() - start) / 1000} seconds`
|
`Build successfully in ${(Date.now() - start) / 1000} seconds`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (metafile) {
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
`dist/${path.basename(outfile)}.meta.json`,
|
`dist/${path.basename(outfile)}.meta.json`,
|
||||||
JSON.stringify(result.metafile)
|
JSON.stringify(result.metafile)
|
||||||
)
|
)
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue