From 429f331c212d598b0d7ff44f20f75cf007bcf32b Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Wed, 2 Aug 2023 20:53:13 -0700 Subject: [PATCH] make ci also run on windows, re-add css minification --- .github/workflows/ci.yaml | 2 +- quartz/bootstrap-cli.mjs | 11 ++++++++++- quartz/build.ts | 12 +++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 41c602315..896086590 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,7 +7,7 @@ on: jobs: build-and-test: - runs-on: ubuntu-22.04 + runs-on: [windows-latest, macos-13, ubuntu-22.04] permissions: contents: write steps: diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs index 75f646bd5..0bf27aa4d 100755 --- a/quartz/bootstrap-cli.mjs +++ b/quartz/bootstrap-cli.mjs @@ -11,7 +11,7 @@ import { intro, isCancel, outro, select, text } from "@clack/prompts" import { rimraf } from "rimraf" import prettyBytes from "pretty-bytes" import { spawnSync } from "child_process" -import { transform } from "lightningcss" +import { transform as cssTransform } from "lightningcss" const UPSTREAM_NAME = "upstream" const QUARTZ_SOURCE_BRANCH = "v4-alpha" @@ -115,6 +115,7 @@ async function stashContentFolder(contentFolder) { } async function popContentFolder(contentFolder) { + await fs.promises.rm(contentFolder, { force: true, recursive: true }) await fs.promises.cp(contentCacheFolder, contentFolder, { force: true, recursive: true, @@ -304,6 +305,14 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started. 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", diff --git a/quartz/build.ts b/quartz/build.ts index 093025aef..9bd1e670e 100644 --- a/quartz/build.ts +++ b/quartz/build.ts @@ -42,11 +42,13 @@ async function buildQuartz(argv: Argv, version: string) { console.log(`Cleaned output directory \`${output}\` in ${perf.timeSince("clean")}`) perf.addEvent("glob") - const fps = (await globby("**/*.md", { - cwd: argv.directory, - ignore: cfg.configuration.ignorePatterns, - gitignore: true, - })).map(fp => fp.split(path.sep).join(path.posix.sep)) + const fps = ( + await globby("**/*.md", { + cwd: argv.directory, + ignore: cfg.configuration.ignorePatterns, + gitignore: true, + }) + ).map((fp) => fp.split(path.sep).join(path.posix.sep)) console.log( `Found ${fps.length} input files from \`${argv.directory}\` in ${perf.timeSince("glob")}`, )