From 3244f1c41a7d77e296ea59a2bb4059a8e73b6a98 Mon Sep 17 00:00:00 2001 From: caipira113 Date: Thu, 2 Nov 2023 00:33:14 +0900 Subject: [PATCH] fix code highlighter --- .github/workflows/docker-deploy.yml | 2 +- package.json | 2 +- packages/frontend/src/scripts/code-highlighter.ts | 4 ++-- scripts/{build-locales.mjs => build-deploy.mjs} | 8 ++++++++ 4 files changed, 12 insertions(+), 4 deletions(-) rename scripts/{build-locales.mjs => build-deploy.mjs} (60%) diff --git a/.github/workflows/docker-deploy.yml b/.github/workflows/docker-deploy.yml index 451055e68c..06c30bae39 100644 --- a/.github/workflows/docker-deploy.yml +++ b/.github/workflows/docker-deploy.yml @@ -71,7 +71,7 @@ jobs: NODE_ENV=production pnpm build-pre NODE_ENV=production pnpm --filter cherrypick-js build NODE_ENV=production pnpm --filter frontend build - NODE_ENV=production pnpm build-locales + NODE_ENV=production pnpm build-deploy - name: Deploy static run: | mv built/_frontend_dist_ built/assets diff --git a/package.json b/package.json index 216ad78257..e1db8ffa9d 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "build-pre": "node ./scripts/build-pre.js", "build-assets": "node ./scripts/build-assets.mjs", "build-assets-d": "node ./scripts/build-assets-d.mjs", - "build-locales": "node ./scripts/build-locales.mjs", + "build-deploy": "node ./scripts/build-deploy.mjs", "build": "pnpm build-pre && pnpm -r build && pnpm build-assets", "build-d": "pnpm -r build && pnpm build-assets-d", "build-storybook": "pnpm --filter frontend build-storybook", diff --git a/packages/frontend/src/scripts/code-highlighter.ts b/packages/frontend/src/scripts/code-highlighter.ts index 957669122e..58ca76260a 100644 --- a/packages/frontend/src/scripts/code-highlighter.ts +++ b/packages/frontend/src/scripts/code-highlighter.ts @@ -1,7 +1,7 @@ import { setWasm, setCDN, Highlighter, getHighlighter as _getHighlighter } from 'shiki'; -setWasm('/assets/shiki/dist/onig.wasm'); -setCDN('/assets/shiki/'); +setWasm(`${_CLIENT_ASSETS_BASE_URL_}/assets/shiki/dist/onig.wasm`); +setCDN(`${_CLIENT_ASSETS_BASE_URL_}/assets/shiki/`); let _highlighter: Highlighter | null = null; diff --git a/scripts/build-locales.mjs b/scripts/build-deploy.mjs similarity index 60% rename from scripts/build-locales.mjs rename to scripts/build-deploy.mjs index 808321da54..6b3bd76461 100644 --- a/scripts/build-locales.mjs +++ b/scripts/build-deploy.mjs @@ -20,9 +20,17 @@ async function copyFrontendLocales() { } } +async function copyFrontendShikiAssets() { + await fs.cp('./packages/frontend/node_modules/shiki/dist', './built/_frontend_dist_/shiki/dist', { dereference: true, recursive: true }); + await fs.cp('./packages/frontend/node_modules/shiki/languages', './built/_frontend_dist_/shiki/languages', { dereference: true, recursive: true }); + await fs.cp('./packages/frontend/node_modules/aiscript-vscode/aiscript/syntaxes', './built/_frontend_dist_/shiki/languages', { dereference: true, recursive: true }); + await fs.cp('./packages/frontend/node_modules/shiki/themes', './built/_frontend_dist_/shiki/themes', { dereference: true, recursive: true }); +} + async function build() { await Promise.all([ copyFrontendLocales(), + copyFrontendShikiAssets(), ]); }