bundleinfo flag, minify scripts

This commit is contained in:
Jacky Zhao 2023-07-23 17:58:35 -07:00
parent 8fd75ffbfd
commit 7c2bb4ee4c
3 changed files with 11 additions and 4 deletions

View File

@ -4,7 +4,6 @@ draft: true
## high priority ## high priority
- attachments path
- inspect bundle size generated by esbuild (it shouldnt be that high) - inspect bundle size generated by esbuild (it shouldnt be that high)
- component resources should be emitted by an emitter - component resources should be emitted by an emitter
- https://help.obsidian.md/Editing+and+formatting/Tags#Nested+tags nested tags?? - https://help.obsidian.md/Editing+and+formatting/Tags#Nested+tags nested tags??

View File

@ -79,6 +79,11 @@ const BuildArgv = {
default: 8080, default: 8080,
describe: "port to serve Quartz on", describe: "port to serve Quartz on",
}, },
bundleInfo: {
boolean: true,
default: false,
describe: "show detailed bundle information"
}
} }
function escapePath(fp) { function escapePath(fp) {
@ -284,6 +289,7 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started.
outfile: path.join("quartz", cacheFile), outfile: path.join("quartz", cacheFile),
bundle: true, bundle: true,
keepNames: true, keepNames: true,
minify: true,
platform: "node", platform: "node",
format: "esm", format: "esm",
jsx: "automatic", jsx: "automatic",
@ -315,6 +321,7 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started.
sourcefile, sourcefile,
}, },
write: false, write: false,
minify: true,
bundle: true, bundle: true,
platform: "browser", platform: "browser",
format: "esm", format: "esm",
@ -338,13 +345,14 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started.
process.exit(1) process.exit(1)
}) })
if (argv.verbose) { if (argv.bundleInfo) {
const outputFileName = "quartz/.quartz-cache/transpiled-build.mjs" const outputFileName = "quartz/.quartz-cache/transpiled-build.mjs"
const meta = result.metafile.outputs[outputFileName] const meta = result.metafile.outputs[outputFileName]
console.log( console.log(
`Successfully transpiled ${Object.keys(meta.inputs).length} files (${prettyBytes( `Successfully transpiled ${Object.keys(meta.inputs).length} files (${prettyBytes(
meta.bytes, meta.bytes,
)})`, )})`)
console.log(await esbuild.analyzeMetafile(result.metafile, { color: true })
) )
} }

View File

@ -1,4 +1,4 @@
import { ContentDetails } from "../../plugins/emitters/contentIndex" import type { ContentDetails } from "../../plugins/emitters/contentIndex"
import * as d3 from "d3" import * as d3 from "d3"
import { registerEscapeHandler, removeAllChildren } from "./util" import { registerEscapeHandler, removeAllChildren } from "./util"
import { CanonicalSlug, getCanonicalSlug, getClientSlug, resolveRelative } from "../../path" import { CanonicalSlug, getCanonicalSlug, getClientSlug, resolveRelative } from "../../path"