| | |
| | | import chokidar from "chokidar" |
| | | import prettyBytes from "pretty-bytes" |
| | | import { execSync, spawnSync } from "child_process" |
| | | import { transform as cssTransform } from "lightningcss" |
| | | 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" |
| | |
| | | default: false, |
| | | describe: "show detailed bundle information", |
| | | }, |
| | | concurrency: { |
| | | number: true, |
| | | describe: "how many threads to use to parse notes", |
| | | }, |
| | | } |
| | | |
| | | function escapePath(fp) { |
| | |
| | | outfile: path.join("quartz", cacheFile), |
| | | bundle: true, |
| | | keepNames: true, |
| | | minify: true, |
| | | minifyWhitespace: true, |
| | | minifySyntax: true, |
| | | platform: "node", |
| | | format: "esm", |
| | | jsx: "automatic", |
| | |
| | | packages: "external", |
| | | metafile: true, |
| | | sourcemap: true, |
| | | sourcesContent: false, |
| | | plugins: [ |
| | | sassPlugin({ |
| | | type: "css-text", |
| | | cssImports: true, |
| | | async transform(css) { |
| | | const { code } = cssTransform({ |
| | | filename: "style.css", |
| | | code: Buffer.from(css), |
| | | minify: true, |
| | | }) |
| | | return code.toString() |
| | | }, |
| | | }), |
| | | { |
| | | name: "inline-script-loader", |
| | |
| | | } |
| | | |
| | | // bypass module cache |
| | | const { default: buildQuartz } = await import(cacheFile + `?update=${new Date()}`) |
| | | // https://github.com/nodejs/modules/issues/307 |
| | | const { default: buildQuartz } = await import(cacheFile + `?update=${randomUUID()}`) |
| | | await buildQuartz(argv, clientRefresh) |
| | | clientRefresh() |
| | | } |