diff --git a/packages/astro/e2e/astro-envs.test.js b/packages/astro/e2e/astro-envs.test.js index b80a4fc5f..1a4f4a1ca 100644 --- a/packages/astro/e2e/astro-envs.test.js +++ b/packages/astro/e2e/astro-envs.test.js @@ -18,9 +18,11 @@ test.describe('Astro Environment BASE_URL', () => { await page.goto(astro.resolveUrl('/blog/')); const astroBaseUrl = page.locator('id=astro-base-url'); - await expect(astroBaseUrl, 'astroBaseUrl equals to /blog/').toHaveText('/blog/') - - const clientComponentBaseUrl = page.locator('id=client-component-base-url'); - await expect(clientComponentBaseUrl, 'clientComponentBaseUrl equals to /blog').toHaveText('/blog/') + await expect(astroBaseUrl, 'astroBaseUrl equals to /blog/').toHaveText('/blog/'); + + const clientComponentBaseUrl = page.locator('id=client-component-base-url'); + await expect(clientComponentBaseUrl, 'clientComponentBaseUrl equals to /blog').toHaveText( + '/blog/' + ); }); }); diff --git a/packages/astro/src/core/compile/compile.ts b/packages/astro/src/core/compile/compile.ts index 9ba2e1531..3376aa529 100644 --- a/packages/astro/src/core/compile/compile.ts +++ b/packages/astro/src/core/compile/compile.ts @@ -1,5 +1,5 @@ -import path from 'path'; import type { TransformResult } from '@astrojs/compiler'; +import path from 'path'; import type { AstroConfig } from '../../@types/astro'; import type { TransformStyle } from './types'; diff --git a/packages/astro/src/core/dev/index.ts b/packages/astro/src/core/dev/index.ts index 535d74986..2979deeff 100644 --- a/packages/astro/src/core/dev/index.ts +++ b/packages/astro/src/core/dev/index.ts @@ -53,7 +53,9 @@ export default async function dev( include: rendererClientEntries, }, define: { - 'import.meta.env.BASE_URL': settings.config.base ? `'${settings.config.base}'` : 'undefined', + 'import.meta.env.BASE_URL': settings.config.base + ? `'${settings.config.base}'` + : 'undefined', }, }, { settings, logging: options.logging, mode: 'dev' } diff --git a/packages/astro/src/vite-plugin-astro-postprocess/index.ts b/packages/astro/src/vite-plugin-astro-postprocess/index.ts index 83e640e42..e120db061 100644 --- a/packages/astro/src/vite-plugin-astro-postprocess/index.ts +++ b/packages/astro/src/vite-plugin-astro-postprocess/index.ts @@ -1,4 +1,3 @@ -import npath from 'path'; import { parse as babelParser } from '@babel/parser'; import type { ArrowFunctionExpressionKind, @@ -6,6 +5,7 @@ import type { StringLiteralKind, } from 'ast-types/gen/kinds'; import type { NodePath } from 'ast-types/lib/node-path'; +import npath from 'path'; import { parse, print, types, visit } from 'recast'; import type { Plugin } from 'vite'; import type { AstroSettings } from '../@types/astro';