mirror of
https://github.com/withastro/astro.git
synced 2025-02-24 22:46:02 -05:00
Allowing Vite to handle base config for deploying to subpaths (#3178)
* Revert "Improvements to build and dev when building for subpaths (#3156)"
This reverts commit 637919c8b6
.
* letting Vite handle base paths
* test updates to expect Astro.request.url to no longer include subpaths
* bringing back the fix for including subpaths in injects scripts and styles
* fixing the static-build test to handle subpaths for injected CSS
* fixing asset import URLs when using base subpaths
* chore: fixing typo in the comments
* Astro needs to manage base in dev to maintain Astro.request.url
* fix: reverting dev routing tests to expect existing behavior
* reverting Astro global test to verify existing behavior
* chore: adding changeset
* test: update static-build tests to verify the subpath is used in asset imports
This commit is contained in:
parent
f67832ebf7
commit
19e1686b87
4 changed files with 11 additions and 3 deletions
5
.changeset/pretty-pumpkins-work.md
Normal file
5
.changeset/pretty-pumpkins-work.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes an issue that was breaking asset and stylesheet URLs when building for a subpath
|
|
@ -162,7 +162,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
|
||||||
root: viteConfig.root,
|
root: viteConfig.root,
|
||||||
envPrefix: 'PUBLIC_',
|
envPrefix: 'PUBLIC_',
|
||||||
server: viteConfig.server,
|
server: viteConfig.server,
|
||||||
base: astroConfig.site ? new URL(astroConfig.site).pathname : '/',
|
base: astroConfig.base,
|
||||||
ssr: viteConfig.ssr,
|
ssr: viteConfig.ssr,
|
||||||
resolve: viteConfig.resolve,
|
resolve: viteConfig.resolve,
|
||||||
} as ViteConfigWithSSR;
|
} as ViteConfigWithSSR;
|
||||||
|
|
|
@ -14,7 +14,7 @@ import load, { resolve, ProloadError } from '@proload/core';
|
||||||
import loadTypeScript from '@proload/plugin-tsm';
|
import loadTypeScript from '@proload/plugin-tsm';
|
||||||
import postcssrc from 'postcss-load-config';
|
import postcssrc from 'postcss-load-config';
|
||||||
import { arraify, isObject } from './util.js';
|
import { arraify, isObject } from './util.js';
|
||||||
import { appendForwardSlash, trimSlashes } from './path.js';
|
import { appendForwardSlash, prependForwardSlash, trimSlashes } from './path.js';
|
||||||
|
|
||||||
load.use([loadTypeScript]);
|
load.use([loadTypeScript]);
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ export const AstroConfigSchema = z.object({
|
||||||
.string()
|
.string()
|
||||||
.optional()
|
.optional()
|
||||||
.default('/')
|
.default('/')
|
||||||
.transform((val) => appendForwardSlash(trimSlashes(val))),
|
.transform((val) => prependForwardSlash(appendForwardSlash(trimSlashes(val)))),
|
||||||
trailingSlash: z
|
trailingSlash: z
|
||||||
.union([z.literal('always'), z.literal('never'), z.literal('ignore')])
|
.union([z.literal('always'), z.literal('never'), z.literal('ignore')])
|
||||||
.optional()
|
.optional()
|
||||||
|
|
|
@ -96,6 +96,9 @@ describe('Static build', () => {
|
||||||
for (const link of links) {
|
for (const link of links) {
|
||||||
const href = $(link).attr('href');
|
const href = $(link).attr('href');
|
||||||
|
|
||||||
|
// The imported .scss file should include the base subpath in the href
|
||||||
|
expect(href.startsWith('/subpath/')).to.be.true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The link should be built with the config's `base` included
|
* The link should be built with the config's `base` included
|
||||||
* as a subpath.
|
* as a subpath.
|
||||||
|
|
Loading…
Add table
Reference in a new issue