Browse Source

Show bundle analysis on build

pull/7/head
coomdev 2 years ago
parent
commit
200f833748
  1. 7
      build.js

7
build.js

@ -22,13 +22,16 @@ const extheader = `// ==UserScript==
`; `;
(async () => { (async () => {
await require('esbuild').build({ let res = await require('esbuild').build({
entryPoints: ['src/main.ts'], entryPoints: ['src/main.ts'],
bundle: true, bundle: true,
outfile: 'dist/main.js', outfile: 'dist/main.js',
define: { define: {
global: 'window' global: 'window'
} },
inject: ['./esbuild.inject.js'],
metafile: true
}); });
console.log(Object.entries(res.metafile.inputs).sort((a, b) => a[1].bytes - b[1].bytes).map(e => `${e[0]} -> ${e[1].bytes}`).join('\n'));
writeFileSync('./main.user.js', extheader + readFileSync('./dist/main.js')); writeFileSync('./main.user.js', extheader + readFileSync('./dist/main.js'));
})(); })();

Loading…
Cancel
Save