From 657b5fc8d07b6cb67a206890c0d613448e6cf6d4 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 23 Sep 2024 20:45:22 +0200 Subject: [PATCH] chore: fix build --- src/components/SnippetPreview.vue | 2 +- src/utils/shiki.ts | 28 ++++++++++------------------ vite.config.ts | 3 +++ 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/components/SnippetPreview.vue b/src/components/SnippetPreview.vue index 7bd0a4e..26705ce 100644 --- a/src/components/SnippetPreview.vue +++ b/src/components/SnippetPreview.vue @@ -20,7 +20,7 @@ async function onShow() { const highlightCode = computedAsync(async () => { const c = code.value - const formatted = await prettierCode(c, props.snippet.prettierParser) + const formatted = (await prettierCode(c, props.snippet.prettierParser)).trim() return highlight(formatted, props.snippet.lang) }) diff --git a/src/utils/shiki.ts b/src/utils/shiki.ts index 1910537..fec6463 100644 --- a/src/utils/shiki.ts +++ b/src/utils/shiki.ts @@ -1,28 +1,20 @@ import type { HighlighterCore } from 'shiki/core' -import { createHighlighterCore } from 'shiki/core' -import langAstro from 'shiki/langs/astro.mjs' -import langHtml from 'shiki/langs/html.mjs' -import langJsx from 'shiki/langs/jsx.mjs' -import langSvelte from 'shiki/langs/svelte.mjs' -import langTsx from 'shiki/langs/tsx.mjs' -import langVue from 'shiki/langs/vue.mjs' -import vitesseDark from 'shiki/themes/vitesse-dark.mjs' -import vitesseLight from 'shiki/themes/vitesse-light.mjs' +import { createHighlighterCore, createJavaScriptRegexEngine } from 'shiki/core' export const shiki = computedAsync(async (onCancel) => { const shiki = await createHighlighterCore({ - loadWasm: () => import('shiki/wasm'), + engine: createJavaScriptRegexEngine(), themes: [ - vitesseDark, - vitesseLight, + () => import('shiki/themes/vitesse-dark.mjs'), + () => import('shiki/themes/vitesse-light.mjs'), ], langs: [ - langHtml, - langJsx, - langTsx, - langVue, - langAstro, - langSvelte, + () => import('shiki/langs/html.mjs'), + () => import('shiki/langs/jsx.mjs'), + () => import('shiki/langs/tsx.mjs'), + () => import('shiki/langs/vue.mjs'), + () => import('shiki/langs/astro.mjs'), + () => import('shiki/langs/svelte.mjs'), ], }) diff --git a/vite.config.ts b/vite.config.ts index eccc355..36bf62e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -82,6 +82,9 @@ export default defineConfig(({ mode }) => { }, ], }, + injectManifest: { + maximumFileSizeToCacheInBytes: 5 * 1024 * 1024, + }, integration: { configureOptions(viteConfig, options) { if (viteConfig.command === 'build')