Skip to content

docs(custom-esbuild): document target.configuration in plugin and indexHtmlTransformer#2192

Open
just-jeb wants to merge 2 commits into
masterfrom
fix/1710-document-target-configuration
Open

docs(custom-esbuild): document target.configuration in plugin and indexHtmlTransformer#2192
just-jeb wants to merge 2 commits into
masterfrom
fix/1710-document-target-configuration

Conversation

@just-jeb
Copy link
Copy Markdown
Owner

@just-jeb just-jeb commented Apr 27, 2026

PR Checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[x] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

The target.configuration (active --configuration flag) is available in both factory plugins and indexHtmlTransformer functions, but this was not shown in the README examples, leaving users unable to discover how to access it.

Issue Number: #1710, #1690

What is the new behavior?

  • Factory plugin README example now shows target.project and target.configuration usage
  • indexHtmlTransformer JS and TS examples now include the target parameter with usage comments
  • New integration test target-options-in-plugin-and-transformer verifies target.configuration is accessible at runtime (via bundle define and <meta> tag in index.html)

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

The feature was already implemented and working — this PR documents it and adds a runtime test to prevent regression.

Copy link
Copy Markdown
Owner Author

@just-jeb just-jeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it actually test that the functionality works? Where's the actual test (except building)? What makes sure that the the config is on HTML?

"cypress:open": "cypress open",
"cypress:run": "cypress run"
"cypress:run": "cypress run",
"build-target-options": "ng build --configuration target-options-test && node -e \"const fs = require('fs');const dist = 'dist/sanity-esbuild-app/browser';const indexHtml = fs.readFileSync(dist + '/index.html', 'utf8');const jsFiles = fs.readdirSync(dist).filter(f => f.endsWith('.js'));const mainJs = jsFiles.map(f => fs.readFileSync(dist + '/' + f, 'utf8')).join('');if (!indexHtml.includes('content=\\\"target-options-test\\\"')) { console.error('FAIL: indexHtmlTransformer did not inject configuration into index.html'); process.exit(1); }if (!mainJs.includes('target-options-test')) { console.error('FAIL: plugin did not inject buildConfiguration into JS bundle'); process.exit(1); }console.log('PASS: target.configuration is accessible in both plugin and indexHtmlTransformer');\""
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlining such a script in package.json is a no go. There's a more elegant solution

…exHtmlTransformer

- Add target.configuration to the factory plugin example in README (alongside
  the existing target.project usage), with inline comments explaining each field
- Update indexHtmlTransformer examples (both JS and TS) to include the target
  param with comments showing target.configuration and target.project
- Add integration test 'target-options-in-plugin-and-transformer' that does a
  real ng build with a factory plugin and indexHtmlTransformer both reading
  target.configuration, then verifies the value appears in the JS bundle and
  index.html meta tag — confirming the feature works end-to-end
- Add esbuild/define-configuration-plugin.js and esbuild/configuration-transformer.js
  to sanity-esbuild-app as the test fixtures

Closes #1710
Closes #1690
@just-jeb just-jeb force-pushed the fix/1710-document-target-configuration branch from afb928e to a6c3dcb Compare May 17, 2026 10:30
The integration test previously inlined a multi-line node -e script in package.json
(per Jeb's review on PR #2192). Moves the verification to scripts/verify-target-options.js
and calls it from the build-target-options npm script. Restores trailing newlines in
package.json and angular.json that were dropped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant