diff --git a/.changeset/pink-ghosts-end.md b/.changeset/pink-ghosts-end.md new file mode 100644 index 000000000..7eaa13010 --- /dev/null +++ b/.changeset/pink-ghosts-end.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +fix: build fail upon have 'process.env' in \*.md file. diff --git a/packages/astro/src/vite-plugin-utils/index.ts b/packages/astro/src/vite-plugin-utils/index.ts index fb10de1ee..b9cc60576 100644 --- a/packages/astro/src/vite-plugin-utils/index.ts +++ b/packages/astro/src/vite-plugin-utils/index.ts @@ -14,7 +14,9 @@ import { viteID } from '../core/util.js'; * in our JS representation of modules like Markdown */ export function escapeViteEnvReferences(code: string) { - return code.replace(/import\.meta\.env/g, 'import\\u002Emeta.env'); + return code + .replace(/import\.meta\.env/g, 'import\\u002Emeta.env') + .replace(/process\.env/g, 'process\\u002Eenv'); } export function getFileInfo(id: string, config: AstroConfig) {