* fix: fix bug #5267 * fix: add changeset * fix: on frozen lockfile Co-authored-by: wuls <linsheng.wu@beantechs.com>
This commit is contained in:
parent
f20ff17aa3
commit
247eb7411f
8 changed files with 67 additions and 2 deletions
5
.changeset/two-ties-tap.md
Normal file
5
.changeset/two-ties-tap.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
have not founded style when srcDir was root
|
|
@ -1,4 +1,7 @@
|
||||||
import { defineConfig } from 'astro/config';
|
import { defineConfig } from 'astro/config';
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({});
|
export default defineConfig({
|
||||||
|
srcDir: '.',
|
||||||
|
root: '.'
|
||||||
|
});
|
||||||
|
|
|
@ -42,7 +42,7 @@ export default function astro({ settings, logging }: AstroPluginOptions): vite.P
|
||||||
|
|
||||||
// Variables for determining if an id starts with /src...
|
// Variables for determining if an id starts with /src...
|
||||||
const srcRootWeb = config.srcDir.pathname.slice(config.root.pathname.length - 1);
|
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) =>
|
const isFullFilePath = (path: string) =>
|
||||||
path.startsWith(prependForwardSlash(slash(fileURLToPath(config.root))));
|
path.startsWith(prependForwardSlash(slash(fileURLToPath(config.root))));
|
||||||
|
|
||||||
|
|
7
packages/astro/test/fixtures/root-srcdir-css/astro.config.mjs
vendored
Normal file
7
packages/astro/test/fixtures/root-srcdir-css/astro.config.mjs
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import { defineConfig } from 'astro/config';
|
||||||
|
|
||||||
|
// https://astro.build/config
|
||||||
|
export default defineConfig({
|
||||||
|
srcDir: '.',
|
||||||
|
root: '.'
|
||||||
|
});
|
8
packages/astro/test/fixtures/root-srcdir-css/package.json
vendored
Normal file
8
packages/astro/test/fixtures/root-srcdir-css/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "@test/remote-css",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"astro": "workspace:*"
|
||||||
|
}
|
||||||
|
}
|
12
packages/astro/test/fixtures/root-srcdir-css/pages/index.astro
vendored
Normal file
12
packages/astro/test/fixtures/root-srcdir-css/pages/index.astro
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
---
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
body { color: green; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>when the srcDir is root</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
24
packages/astro/test/root-srcdir-css.test.js
Normal file
24
packages/astro/test/root-srcdir-css.test.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import { expect } from 'chai';
|
||||||
|
import * as cheerio from 'cheerio';
|
||||||
|
import { loadFixture } from './test-utils.js';
|
||||||
|
|
||||||
|
describe('srcDir', () => {
|
||||||
|
let fixture;
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
fixture = await loadFixture({
|
||||||
|
root: './fixtures/root-srcdir-css/',
|
||||||
|
});
|
||||||
|
await fixture.build();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('when the srcDir is "." which parser style in index.astro', async () => {
|
||||||
|
const html = await fixture.readFile('/index.html');
|
||||||
|
const $ = cheerio.load(html);
|
||||||
|
|
||||||
|
const relPath = $('link').attr('href');
|
||||||
|
const css = await fixture.readFile(relPath);
|
||||||
|
console.log(css)
|
||||||
|
expect(css).to.match(/body{color:green}/);
|
||||||
|
});
|
||||||
|
});
|
|
@ -2079,6 +2079,12 @@ importers:
|
||||||
dependencies:
|
dependencies:
|
||||||
astro: link:../../..
|
astro: link:../../..
|
||||||
|
|
||||||
|
packages/astro/test/fixtures/root-srcdir-css:
|
||||||
|
specifiers:
|
||||||
|
astro: workspace:*
|
||||||
|
dependencies:
|
||||||
|
astro: link:../../..
|
||||||
|
|
||||||
packages/astro/test/fixtures/route-manifest:
|
packages/astro/test/fixtures/route-manifest:
|
||||||
specifiers:
|
specifiers:
|
||||||
astro: workspace:*
|
astro: workspace:*
|
||||||
|
|
Loading…
Reference in a new issue