fix(angular): resolve the index html transformer correctly for esbuild based build targets in dev-server (#21679)
This commit is contained in:
parent
bf45f08992
commit
db4c617c2c
@ -24,6 +24,7 @@ import { combineLatest, from } from 'rxjs';
|
|||||||
import { switchMap } from 'rxjs/operators';
|
import { switchMap } from 'rxjs/operators';
|
||||||
import { getInstalledAngularVersionInfo } from '../../executors/utilities/angular-version-utils';
|
import { getInstalledAngularVersionInfo } from '../../executors/utilities/angular-version-utils';
|
||||||
import {
|
import {
|
||||||
|
loadIndexHtmlTransformer,
|
||||||
loadMiddleware,
|
loadMiddleware,
|
||||||
loadPlugins,
|
loadPlugins,
|
||||||
type PluginSpec,
|
type PluginSpec,
|
||||||
@ -182,8 +183,22 @@ export function executeDevServerBuilder(
|
|||||||
from(
|
from(
|
||||||
loadMiddleware(options.esbuildMiddleware, buildTargetOptions.tsConfig)
|
loadMiddleware(options.esbuildMiddleware, buildTargetOptions.tsConfig)
|
||||||
),
|
),
|
||||||
|
from(
|
||||||
|
loadIndexHtmlFileTransformer(
|
||||||
|
pathToIndexFileTransformer,
|
||||||
|
buildTargetOptions.tsConfig,
|
||||||
|
context,
|
||||||
|
isUsingWebpackBuilder
|
||||||
|
)
|
||||||
|
),
|
||||||
]).pipe(
|
]).pipe(
|
||||||
switchMap(([{ executeDevServerBuilder }, plugins, middleware]) =>
|
switchMap(
|
||||||
|
([
|
||||||
|
{ executeDevServerBuilder },
|
||||||
|
plugins,
|
||||||
|
middleware,
|
||||||
|
indexHtmlTransformer,
|
||||||
|
]) =>
|
||||||
executeDevServerBuilder(
|
executeDevServerBuilder(
|
||||||
delegateBuilderOptions,
|
delegateBuilderOptions,
|
||||||
context,
|
context,
|
||||||
@ -223,13 +238,9 @@ export function executeDevServerBuilder(
|
|||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|
||||||
...(pathToIndexFileTransformer
|
...(indexHtmlTransformer
|
||||||
? {
|
? {
|
||||||
indexHtml: resolveIndexHtmlTransformer(
|
indexHtml: indexHtmlTransformer,
|
||||||
pathToIndexFileTransformer,
|
|
||||||
buildTargetOptions.tsConfig,
|
|
||||||
context.target
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
},
|
},
|
||||||
@ -267,6 +278,25 @@ function getDelegateBuilderOptions(
|
|||||||
return delegateBuilderOptions;
|
return delegateBuilderOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadIndexHtmlFileTransformer(
|
||||||
|
pathToIndexFileTransformer: string | undefined,
|
||||||
|
tsConfig: string,
|
||||||
|
context: BuilderContext,
|
||||||
|
isUsingWebpackBuilder: boolean
|
||||||
|
) {
|
||||||
|
if (!pathToIndexFileTransformer) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isUsingWebpackBuilder
|
||||||
|
? resolveIndexHtmlTransformer(
|
||||||
|
pathToIndexFileTransformer,
|
||||||
|
tsConfig,
|
||||||
|
context.target
|
||||||
|
)
|
||||||
|
: await loadIndexHtmlTransformer(pathToIndexFileTransformer, tsConfig);
|
||||||
|
}
|
||||||
|
|
||||||
const executorToBuilderMap = new Map<string, string>([
|
const executorToBuilderMap = new Map<string, string>([
|
||||||
[
|
[
|
||||||
'@nx/angular:browser-esbuild',
|
'@nx/angular:browser-esbuild',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user