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",
|
"x-priority": "important",
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"indexFileTransformer": {
|
"indexHtmlTransformer": {
|
||||||
"description": "Path to transformer function to transform the index.html",
|
"description": "Path to transformer function to transform the index.html",
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"alias": "indexFileTransformer"
|
||||||
},
|
},
|
||||||
"buildLibsFromSource": {
|
"buildLibsFromSource": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|||||||
@ -44,6 +44,7 @@ type BuildTargetOptions = {
|
|||||||
tsConfig: string;
|
tsConfig: string;
|
||||||
buildLibsFromSource?: boolean;
|
buildLibsFromSource?: boolean;
|
||||||
customWebpackConfig?: { path?: string };
|
customWebpackConfig?: { path?: string };
|
||||||
|
indexHtmlTransformer?: string;
|
||||||
indexFileTransformer?: string;
|
indexFileTransformer?: string;
|
||||||
plugins?: string[] | PluginSpec[];
|
plugins?: string[] | PluginSpec[];
|
||||||
esbuildMiddleware?: string[];
|
esbuildMiddleware?: string[];
|
||||||
@ -111,11 +112,14 @@ export function executeDevServerBuilder(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const normalizedIndexHtmlTransformer =
|
||||||
|
buildTargetOptions.indexHtmlTransformer ??
|
||||||
|
buildTargetOptions.indexFileTransformer;
|
||||||
let pathToIndexFileTransformer: string;
|
let pathToIndexFileTransformer: string;
|
||||||
if (buildTargetOptions.indexFileTransformer) {
|
if (normalizedIndexHtmlTransformer) {
|
||||||
pathToIndexFileTransformer = joinPathFragments(
|
pathToIndexFileTransformer = joinPathFragments(
|
||||||
context.workspaceRoot,
|
context.workspaceRoot,
|
||||||
buildTargetOptions.indexFileTransformer
|
normalizedIndexHtmlTransformer
|
||||||
);
|
);
|
||||||
|
|
||||||
if (pathToIndexFileTransformer && !existsSync(pathToIndexFileTransformer)) {
|
if (pathToIndexFileTransformer && !existsSync(pathToIndexFileTransformer)) {
|
||||||
@ -313,6 +317,7 @@ function cleanBuildTargetOptions(
|
|||||||
| BrowserEsbuildBuilderOptions {
|
| BrowserEsbuildBuilderOptions {
|
||||||
delete options.buildLibsFromSource;
|
delete options.buildLibsFromSource;
|
||||||
delete options.customWebpackConfig;
|
delete options.customWebpackConfig;
|
||||||
|
delete options.indexHtmlTransformer;
|
||||||
delete options.indexFileTransformer;
|
delete options.indexFileTransformer;
|
||||||
delete options.plugins;
|
delete options.plugins;
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,10 @@ export type BrowserBuilderSchema = Schema & {
|
|||||||
customWebpackConfig?: {
|
customWebpackConfig?: {
|
||||||
path: string;
|
path: string;
|
||||||
};
|
};
|
||||||
indexFileTransformer?: string;
|
indexHtmlTransformer?: string;
|
||||||
buildLibsFromSource?: boolean;
|
buildLibsFromSource?: boolean;
|
||||||
|
/**
|
||||||
|
* @deprecated Use `indexHtmlTransformer` instead. It will be removed in Nx 19.
|
||||||
|
*/
|
||||||
|
indexFileTransformer?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -458,9 +458,10 @@
|
|||||||
"x-priority": "important",
|
"x-priority": "important",
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"indexFileTransformer": {
|
"indexHtmlTransformer": {
|
||||||
"description": "Path to transformer function to transform the index.html",
|
"description": "Path to transformer function to transform the index.html",
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"alias": "indexFileTransformer"
|
||||||
},
|
},
|
||||||
"buildLibsFromSource": {
|
"buildLibsFromSource": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|||||||
@ -55,6 +55,7 @@ export function executeWebpackBrowserBuilder(
|
|||||||
const {
|
const {
|
||||||
buildLibsFromSource,
|
buildLibsFromSource,
|
||||||
customWebpackConfig,
|
customWebpackConfig,
|
||||||
|
indexHtmlTransformer,
|
||||||
indexFileTransformer,
|
indexFileTransformer,
|
||||||
...delegateBuilderOptions
|
...delegateBuilderOptions
|
||||||
} = options;
|
} = options;
|
||||||
@ -71,9 +72,11 @@ export function executeWebpackBrowserBuilder(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const normalizedIndexHtmlTransformer =
|
||||||
|
indexHtmlTransformer ?? indexFileTransformer;
|
||||||
const pathToIndexFileTransformer =
|
const pathToIndexFileTransformer =
|
||||||
indexFileTransformer &&
|
normalizedIndexHtmlTransformer &&
|
||||||
joinPathFragments(context.workspaceRoot, indexFileTransformer);
|
joinPathFragments(context.workspaceRoot, normalizedIndexHtmlTransformer);
|
||||||
if (pathToIndexFileTransformer && !existsSync(pathToIndexFileTransformer)) {
|
if (pathToIndexFileTransformer && !existsSync(pathToIndexFileTransformer)) {
|
||||||
throw new Error(
|
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}`
|
`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