mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-22 15:02:11 +08:00
refactor(@angular/build): also add server.preTransformRequests
5c1360179c
moved `preTransformRequests` from the `server` to `dev` section. But vite, still uses the `server` section in such casesbcdb51a1ac/packages/vite/src/node/server/index.ts (L673)
andbcdb51a1ac/packages/vite/src/node/server/middlewares/indexHtml.ts (L475)
This commit is contained in:
parent
414736bc0f
commit
17a7b8cf01
@ -734,6 +734,7 @@ function updateResultRecord(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line max-lines-per-function
|
||||||
export async function setupServer(
|
export async function setupServer(
|
||||||
serverOptions: NormalizedDevServerOptions,
|
serverOptions: NormalizedDevServerOptions,
|
||||||
outputFiles: Map<string, OutputFileRecord>,
|
outputFiles: Map<string, OutputFileRecord>,
|
||||||
@ -776,6 +777,15 @@ export async function setupServer(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required when using `externalDependencies` to prevent Vite load errors.
|
||||||
|
*
|
||||||
|
* @note Can be removed if Vite introduces native support for externals.
|
||||||
|
* @note Vite misresolves browser modules in SSR when accessing URLs with multiple segments
|
||||||
|
* (e.g., 'foo/bar'), as they are not correctly re-based from the base href.
|
||||||
|
*/
|
||||||
|
const preTransformRequests =
|
||||||
|
externalMetadata.explicitBrowser.length === 0 && ssrMode === ServerSsrMode.NoSsr;
|
||||||
const cacheDir = join(serverOptions.cacheOptions.path, serverOptions.buildTarget.project, 'vite');
|
const cacheDir = join(serverOptions.cacheOptions.path, serverOptions.buildTarget.project, 'vite');
|
||||||
const configuration: InlineConfig = {
|
const configuration: InlineConfig = {
|
||||||
configFile: false,
|
configFile: false,
|
||||||
@ -806,15 +816,10 @@ export async function setupServer(
|
|||||||
preserveSymlinks,
|
preserveSymlinks,
|
||||||
},
|
},
|
||||||
dev: {
|
dev: {
|
||||||
// This is needed when `externalDependencies` is used to prevent Vite load errors.
|
preTransformRequests,
|
||||||
// NOTE: If Vite adds direct support for externals, this can be removed.
|
|
||||||
// NOTE: Vite breaks the resolution of browser modules in SSR
|
|
||||||
// when accessing a url with two or more segments (e.g., 'foo/bar'),
|
|
||||||
// as they are not re-based from the base href.
|
|
||||||
preTransformRequests:
|
|
||||||
externalMetadata.explicitBrowser.length === 0 && ssrMode === ServerSsrMode.NoSsr,
|
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
|
preTransformRequests,
|
||||||
warmup: {
|
warmup: {
|
||||||
ssrFiles,
|
ssrFiles,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user