mirror of
https://github.com/moebooru/moebooru
synced 2025-08-22 09:57:31 +00:00
Analyze option for build script
This commit is contained in:
parent
08e81466cb
commit
b0e6618c81
24
build.js
24
build.js
@ -11,6 +11,19 @@ const outfileEsbuildPath = `${outdir}/${outfileEsbuild}`
|
||||
const outfileBabel = 'application.js'
|
||||
const outfileBabelPath = `${outdir}/${outfileBabel}`
|
||||
|
||||
const analyzeOnEnd = {
|
||||
name: 'analyzeOnEnd',
|
||||
setup (build) {
|
||||
build.onEnd(async (result) => {
|
||||
if (options.analyze) {
|
||||
const analyzeResult = await esbuild.analyzeMetafile(result.metafile)
|
||||
|
||||
console.log(analyzeResult)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const babelOnEnd = {
|
||||
name: 'babelOnEnd',
|
||||
setup (build) {
|
||||
@ -34,13 +47,20 @@ const babelOnEnd = {
|
||||
}
|
||||
}
|
||||
|
||||
const args = process.argv.slice(2)
|
||||
const options = {
|
||||
watch: args.includes('--watch'),
|
||||
analyze: args.includes('--analyze')
|
||||
}
|
||||
|
||||
esbuild.build({
|
||||
bundle: true,
|
||||
entryPoints: ['app/javascript/application.coffee'],
|
||||
metafile: options.analyze,
|
||||
nodePaths: ['app/javascript'],
|
||||
outfile: outfileEsbuildPath,
|
||||
plugins: [coffeeScriptPlugin({ bare: true }), babelOnEnd],
|
||||
plugins: [coffeeScriptPlugin({ bare: true }), babelOnEnd, analyzeOnEnd],
|
||||
resolveExtensions: ['.coffee', '.js'],
|
||||
sourcemap: true,
|
||||
watch: process.argv[2] === '--watch'
|
||||
watch: options.watch
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user