fix(angular): handle indexHtmlTransformer option in dev-server correctly (#21520)
This commit is contained in:
parent
d6d7b1c689
commit
3b5f4a21ce
@ -554,9 +554,10 @@
|
||||
"x-priority": "important",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"indexFileTransformer": {
|
||||
"indexHtmlTransformer": {
|
||||
"description": "Path to transformer function to transform the index.html",
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"alias": "indexFileTransformer"
|
||||
},
|
||||
"buildLibsFromSource": {
|
||||
"type": "boolean",
|
||||
|
||||
@ -44,6 +44,7 @@ type BuildTargetOptions = {
|
||||
tsConfig: string;
|
||||
buildLibsFromSource?: boolean;
|
||||
customWebpackConfig?: { path?: string };
|
||||
indexHtmlTransformer?: string;
|
||||
indexFileTransformer?: string;
|
||||
plugins?: string[] | PluginSpec[];
|
||||
esbuildMiddleware?: string[];
|
||||
@ -111,11 +112,14 @@ export function executeDevServerBuilder(
|
||||
}
|
||||
}
|
||||
|
||||
const normalizedIndexHtmlTransformer =
|
||||
buildTargetOptions.indexHtmlTransformer ??
|
||||
buildTargetOptions.indexFileTransformer;
|
||||
let pathToIndexFileTransformer: string;
|
||||
if (buildTargetOptions.indexFileTransformer) {
|
||||
if (normalizedIndexHtmlTransformer) {
|
||||
pathToIndexFileTransformer = joinPathFragments(
|
||||
context.workspaceRoot,
|
||||
buildTargetOptions.indexFileTransformer
|
||||
normalizedIndexHtmlTransformer
|
||||
);
|
||||
|
||||
if (pathToIndexFileTransformer && !existsSync(pathToIndexFileTransformer)) {
|
||||
@ -313,6 +317,7 @@ function cleanBuildTargetOptions(
|
||||
| BrowserEsbuildBuilderOptions {
|
||||
delete options.buildLibsFromSource;
|
||||
delete options.customWebpackConfig;
|
||||
delete options.indexHtmlTransformer;
|
||||
delete options.indexFileTransformer;
|
||||
delete options.plugins;
|
||||
|
||||
|
||||
@ -4,6 +4,10 @@ export type BrowserBuilderSchema = Schema & {
|
||||
customWebpackConfig?: {
|
||||
path: string;
|
||||
};
|
||||
indexFileTransformer?: string;
|
||||
indexHtmlTransformer?: string;
|
||||
buildLibsFromSource?: boolean;
|
||||
/**
|
||||
* @deprecated Use `indexHtmlTransformer` instead. It will be removed in Nx 19.
|
||||
*/
|
||||
indexFileTransformer?: string;
|
||||
};
|
||||
|
||||
@ -458,9 +458,10 @@
|
||||
"x-priority": "important",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"indexFileTransformer": {
|
||||
"indexHtmlTransformer": {
|
||||
"description": "Path to transformer function to transform the index.html",
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"alias": "indexFileTransformer"
|
||||
},
|
||||
"buildLibsFromSource": {
|
||||
"type": "boolean",
|
||||
|
||||
@ -55,6 +55,7 @@ export function executeWebpackBrowserBuilder(
|
||||
const {
|
||||
buildLibsFromSource,
|
||||
customWebpackConfig,
|
||||
indexHtmlTransformer,
|
||||
indexFileTransformer,
|
||||
...delegateBuilderOptions
|
||||
} = options;
|
||||
@ -71,9 +72,11 @@ export function executeWebpackBrowserBuilder(
|
||||
);
|
||||
}
|
||||
|
||||
const normalizedIndexHtmlTransformer =
|
||||
indexHtmlTransformer ?? indexFileTransformer;
|
||||
const pathToIndexFileTransformer =
|
||||
indexFileTransformer &&
|
||||
joinPathFragments(context.workspaceRoot, indexFileTransformer);
|
||||
normalizedIndexHtmlTransformer &&
|
||||
joinPathFragments(context.workspaceRoot, normalizedIndexHtmlTransformer);
|
||||
if (pathToIndexFileTransformer && !existsSync(pathToIndexFileTransformer)) {
|
||||
throw new Error(
|
||||
`File containing Index File Transformer function Not Found!\n Please ensure the path to the file containing the function is correct: \n${pathToIndexFileTransformer}`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user