Description
Describe the Bug
Hi,
I am currently working on upgrading an Angular 16 application to Angular 17 and I would like to use esbuild.
My application requires index.html transformation. This transformation relies on data from the targetOptions parameter.
With version 16, I was using @angular-builders/custom-webpack
and it was working fine.
Unfortunately, with @angular-builders/custom-esbuild
, the targetOptions are not present during the transformation. Instead, it's the content of the index file.
Yet the documentation indicates that targetOptions should be accessible.
Minimal Reproduction
Just creating a new Angular 17 application (via ng new), and following the instruction of the doc :
- Adding
@angular-builders/custom-esbuild
as a dev dependency - Replacing
@angular-devkit/build-angular:application
with@angular-builders/custom-esbuild:application
and@angular-devkit/build-angular:dev-server
with@angular-builders/custom-esbuild:dev-server
in angular.json - Adding index-html-transformer.ts with the following code :
import { Target } from '@angular-devkit/architect/src/input-schema';
import { json } from '@angular-devkit/core';
type TargetOptions = json.JsonObject & Target;
export default (targetOptions: TargetOptions, indexHtml: string) => {
console.log('targetOptions', targetOptions);
const i = indexHtml.indexOf('</body>');
const config = `<p>Configuration: ${targetOptions.configuration}</p>`;
return `${indexHtml.slice(0, i)}
${config}
${indexHtml.slice(i)}`;
};
- Adding indexHtmlTransformer in angular.json
Here is the result on ng build / ng serve :
Expected Behavior
TargetOptions should be there. Or at least, documentation needs an update.
Environment
Libs
- @angular/core version: 17.2.0
- @angular-devkit/build-angular version: 17.2.1
- @angular-builders/custom-esbuild: 17.1.0
For Tooling issues:
- Node version: 20.11.1
- Platform: Windows