mirror of
https://github.com/moebooru/moebooru
synced 2025-08-28 20:47:42 +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 outfileBabel = 'application.js'
|
||||||
const outfileBabelPath = `${outdir}/${outfileBabel}`
|
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 = {
|
const babelOnEnd = {
|
||||||
name: 'babelOnEnd',
|
name: 'babelOnEnd',
|
||||||
setup (build) {
|
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({
|
esbuild.build({
|
||||||
bundle: true,
|
bundle: true,
|
||||||
entryPoints: ['app/javascript/application.coffee'],
|
entryPoints: ['app/javascript/application.coffee'],
|
||||||
|
metafile: options.analyze,
|
||||||
nodePaths: ['app/javascript'],
|
nodePaths: ['app/javascript'],
|
||||||
outfile: outfileEsbuildPath,
|
outfile: outfileEsbuildPath,
|
||||||
plugins: [coffeeScriptPlugin({ bare: true }), babelOnEnd],
|
plugins: [coffeeScriptPlugin({ bare: true }), babelOnEnd, analyzeOnEnd],
|
||||||
resolveExtensions: ['.coffee', '.js'],
|
resolveExtensions: ['.coffee', '.js'],
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
watch: process.argv[2] === '--watch'
|
watch: options.watch
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user