From 58d8686e94816da649b0210f5288173fb4b9a483 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Tue, 15 Mar 2022 11:26:46 -0400 Subject: [PATCH] Fix for allowing space in folder name (#2797) * Fix for allowing space in folder name * Adds a changeset * Prepend a forward slash, for windows --- .changeset/grumpy-dancers-smell.md | 5 +++++ packages/astro/src/vite-plugin-astro/compile.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/grumpy-dancers-smell.md diff --git a/.changeset/grumpy-dancers-smell.md b/.changeset/grumpy-dancers-smell.md new file mode 100644 index 000000000..691e935a3 --- /dev/null +++ b/.changeset/grumpy-dancers-smell.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix for projects with a folder name containing a space diff --git a/packages/astro/src/vite-plugin-astro/compile.ts b/packages/astro/src/vite-plugin-astro/compile.ts index 4385d9468..f9075e3e7 100644 --- a/packages/astro/src/vite-plugin-astro/compile.ts +++ b/packages/astro/src/vite-plugin-astro/compile.ts @@ -7,6 +7,8 @@ import fs from 'fs'; import { fileURLToPath } from 'url'; import { transform } from '@astrojs/compiler'; import { transformWithVite } from './styles.js'; +import { viteID } from '../core/util.js'; +import { prependForwardSlash } from '../core/path.js'; type CompilationCache = Map; type CompileResult = TransformResult & { rawCSSDeps: Set }; @@ -49,7 +51,7 @@ async function compile(config: AstroConfig, filename: string, source: string, vi site: config.buildOptions.site, sourcefile: filename, sourcemap: 'both', - internalURL: `/@fs${new URL('../runtime/server/index.js', import.meta.url).pathname}`, + internalURL: `/@fs${prependForwardSlash(viteID(new URL('../runtime/server/index.js', import.meta.url)))}`, experimentalStaticExtraction: !config.buildOptions.legacyBuild, // TODO add experimental flag here preprocessStyle: async (value: string, attrs: Record) => {