From 028bcec62c3ca019a96783f17eaee1ecce6e092b Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Mon, 07 Aug 2023 00:09:29 +0000
Subject: [PATCH] mobile fixes, fix bug when linking to anchor on home, docs
---
quartz/bootstrap-cli.mjs | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs
index 40ef34e..8b9bea9 100755
--- a/quartz/bootstrap-cli.mjs
+++ b/quartz/bootstrap-cli.mjs
@@ -16,6 +16,7 @@
import http from "http"
import serveHandler from "serve-handler"
import { WebSocketServer } from "ws"
+import { randomUUID } from "crypto"
const ORIGIN_NAME = "origin"
const UPSTREAM_NAME = "upstream"
@@ -297,7 +298,8 @@
outfile: path.join("quartz", cacheFile),
bundle: true,
keepNames: true,
- minify: true,
+ minifyWhitespace: true,
+ minifySyntax: true,
platform: "node",
format: "esm",
jsx: "automatic",
@@ -305,6 +307,7 @@
packages: "external",
metafile: true,
sourcemap: true,
+ sourcesContent: false,
plugins: [
sassPlugin({
type: "css-text",
@@ -353,9 +356,7 @@
],
})
- let clientRefresh = () => {}
- let closeHandler = null
- const build = async () => {
+ const build = async (clientRefresh) => {
const result = await ctx.rebuild().catch((err) => {
console.error(`${chalk.red("Couldn't parse Quartz configuration:")} ${fp}`)
console.log(`Reason: ${chalk.grey(err)}`)
@@ -374,21 +375,19 @@
}
// bypass module cache
- const { default: buildQuartz } = await import(cacheFile + `?update=${new Date()}`)
- if (closeHandler) {
- await closeHandler()
- }
-
- closeHandler = await buildQuartz(argv, clientRefresh)
+ // https://github.com/nodejs/modules/issues/307
+ const { default: buildQuartz } = await import(cacheFile + `?update=${randomUUID()}`)
+ await buildQuartz(argv, clientRefresh)
clientRefresh()
}
- await build()
if (argv.serve) {
const wss = new WebSocketServer({ port: 3001 })
const connections = []
wss.on("connection", (ws) => connections.push(ws))
- clientRefresh = () => connections.forEach((conn) => conn.send("rebuild"))
+ const clientRefresh = () => connections.forEach((conn) => conn.send("rebuild"))
+
+ await build(clientRefresh)
const server = http.createServer(async (req, res) => {
await serveHandler(req, res, {
public: argv.output,
@@ -412,9 +411,10 @@
})
.on("all", async () => {
console.log(chalk.yellow("Detected a source code change, doing a hard rebuild..."))
- await build()
+ await build(clientRefresh)
})
} else {
+ await build(() => {})
ctx.dispose()
}
})
--
Gitblit v1.10.0