From 8881de21ba5cd356a0bf6015d49ccfd91fb34ded Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sat, 30 Dec 2023 09:35:21 -0800 Subject: [PATCH] chore(docs): use Vite define instead of import --- docs/astro.config.ts | 6 ++++++ docs/src/components/Header.svelte | 4 ++-- docs/src/components/index.svelte | 3 +-- docs/src/constants.ts | 1 + docs/src/env.d.ts | 2 ++ 5 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 docs/src/constants.ts diff --git a/docs/astro.config.ts b/docs/astro.config.ts index ef96f01..6c8c694 100644 --- a/docs/astro.config.ts +++ b/docs/astro.config.ts @@ -1,6 +1,12 @@ import svelte from "@astrojs/svelte"; import { defineConfig } from "astro/config"; +import { version } from "../package.json" assert { type: "json" }; export default defineConfig({ integrations: [svelte()], + vite: { + define: { + __VERSION: JSON.stringify(version), + }, + }, }); diff --git a/docs/src/components/Header.svelte b/docs/src/components/Header.svelte index 452aab6..61eea79 100644 --- a/docs/src/components/Header.svelte +++ b/docs/src/components/Header.svelte @@ -10,7 +10,7 @@ SkipToContent, } from "carbon-components-svelte"; import LogoGithub from "./LogoGithub.svelte"; - import { version } from "../../../package.json"; + import { VERSION } from "../constants";
@@ -20,7 +20,7 @@ Carbon Pictograms Svelte - v{version} + v{VERSION} diff --git a/docs/src/components/index.svelte b/docs/src/components/index.svelte index 11e31f7..5e3abf5 100644 --- a/docs/src/components/index.svelte +++ b/docs/src/components/index.svelte @@ -15,7 +15,6 @@ import fuzzy from "fuzzy"; import Header from "./Header.svelte"; import * as pictograms from "../../../lib"; - import { version } from "../../../package.json"; const { match } = fuzzy; const pictogramNames = Object.keys(pictograms); @@ -34,7 +33,7 @@ -
+
+ +declare const __VERSION: string; \ No newline at end of file