diff --git a/.changeset/two-ties-tap.md b/.changeset/two-ties-tap.md new file mode 100644 index 000000000..15ccf7287 --- /dev/null +++ b/.changeset/two-ties-tap.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +have not founded style when srcDir was root diff --git a/examples/minimal/astro.config.mjs b/examples/minimal/astro.config.mjs index 882e6515a..48d20ba67 100644 --- a/examples/minimal/astro.config.mjs +++ b/examples/minimal/astro.config.mjs @@ -1,4 +1,7 @@ import { defineConfig } from 'astro/config'; // https://astro.build/config -export default defineConfig({}); +export default defineConfig({ + srcDir: '.', + root: '.' +}); diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts index 40f89be7c..fd9b1805d 100644 --- a/packages/astro/src/vite-plugin-astro/index.ts +++ b/packages/astro/src/vite-plugin-astro/index.ts @@ -42,7 +42,7 @@ export default function astro({ settings, logging }: AstroPluginOptions): vite.P // Variables for determining if an id starts with /src... const srcRootWeb = config.srcDir.pathname.slice(config.root.pathname.length - 1); - const isBrowserPath = (path: string) => path.startsWith(srcRootWeb); + const isBrowserPath = (path: string) => path.startsWith(srcRootWeb) && srcRootWeb !== '/'; const isFullFilePath = (path: string) => path.startsWith(prependForwardSlash(slash(fileURLToPath(config.root)))); diff --git a/packages/astro/test/fixtures/root-srcdir-css/astro.config.mjs b/packages/astro/test/fixtures/root-srcdir-css/astro.config.mjs new file mode 100644 index 000000000..48d20ba67 --- /dev/null +++ b/packages/astro/test/fixtures/root-srcdir-css/astro.config.mjs @@ -0,0 +1,7 @@ +import { defineConfig } from 'astro/config'; + +// https://astro.build/config +export default defineConfig({ + srcDir: '.', + root: '.' +}); diff --git a/packages/astro/test/fixtures/root-srcdir-css/package.json b/packages/astro/test/fixtures/root-srcdir-css/package.json new file mode 100644 index 000000000..15f2f8943 --- /dev/null +++ b/packages/astro/test/fixtures/root-srcdir-css/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/remote-css", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/root-srcdir-css/pages/index.astro b/packages/astro/test/fixtures/root-srcdir-css/pages/index.astro new file mode 100644 index 000000000..630adcf06 --- /dev/null +++ b/packages/astro/test/fixtures/root-srcdir-css/pages/index.astro @@ -0,0 +1,12 @@ +--- +--- + +
+ + + +