2.7.5
Export data spreadsheet
This commit is contained in:
@@ -44,6 +44,13 @@ function cleanDist() {
|
||||
for (const f of targets) {
|
||||
try { fs.unlinkSync(f); } catch (_) { /* ok if missing */ }
|
||||
}
|
||||
// Clean up any previously-generated ESM chunks
|
||||
const chunksDir = path.join(ASSETS, 'chunks');
|
||||
if (fs.existsSync(chunksDir)) {
|
||||
for (const f of fs.readdirSync(chunksDir)) {
|
||||
try { fs.unlinkSync(path.join(chunksDir, f)); } catch (_) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively resolve CSS @import statements into one flat string
|
||||
@@ -80,7 +87,8 @@ function rewriteHTML(html, version) {
|
||||
'$1about.min.css?v=' + version + '$2'
|
||||
);
|
||||
const css = ' <link rel="stylesheet" href="./assets/bundle.min.css?v=' + version + '">';
|
||||
const js = ' <script defer src="./assets/bundle.min.js?v=' + version + '"></script>';
|
||||
// ESM module — browser loads chunks automatically on demand (e.g. xlsx-js-style)
|
||||
const js = ' <script type="module" src="./assets/bundle.min.js?v=' + version + '"></script>';
|
||||
html = html.replace('</head>', css + '\n' + js + '\n</head>');
|
||||
return html;
|
||||
}
|
||||
@@ -110,15 +118,17 @@ async function build() {
|
||||
fs.mkdirSync(ASSETS, { recursive: true });
|
||||
console.log(' Output dir ready: dist/');
|
||||
|
||||
// 2. Bundle + minify JavaScript
|
||||
// 2. Bundle + minify JavaScript (ESM with code splitting for lazy chunks)
|
||||
console.log(' Bundling JS...');
|
||||
await esbuild.build({
|
||||
entryPoints: [path.join(ROOT, 'assets/js/main.js')],
|
||||
bundle: true,
|
||||
splitting: true,
|
||||
minify: true,
|
||||
format: 'iife',
|
||||
globalName: 'SunScope',
|
||||
outfile: path.join(ASSETS, 'bundle.min.js'),
|
||||
format: 'esm',
|
||||
entryNames: 'bundle.min',
|
||||
chunkNames: 'chunks/[name]-[hash]',
|
||||
outdir: ASSETS,
|
||||
logLevel: 'warning',
|
||||
plugins: [stripJSXCommentsPlugin],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user