Cannot disable <base /> tag in web application
See original GitHub issueHi!
I’m not entirely sure if this should be a feature request, but going of what I read in the source I suspect the intended behaviour is different that what it’s currently doing.
Current Behavior
When building/compiling a web application, the <base />
tag is always added to the <head />
of the index.html
file.
In our case this gets in the way and we want to turn it of completely.
Expected Behavior
Passing null
or an empty string to the baseHref
option to disable the <base />
tag.
Steps to Reproduce
- Generate a web app in a workspace
- Pass
null
or an empty string to thebaseHref
option of the build/serve target of the application inworkspace.json
- build/serve the application
When passing null
, building/compiling fails altogether, when passing an empty string a <base href="(unknown)" />
is injected.
The augment-index-html
utility seems to (try to) accomodate for excluding a <base />
tag going of this comment. But the condition checks for typeof params.baseHref == 'string'
, and the schema of the build, and serve builder require this to be a string and provides a default value of /
. Thus, the <base />
tag is always added.
To fix this, it seems you can either
- allow
null
to be passed by changing the schema of the builder(s), or - also check if
params.baseHref
is not an empty string.
I’m willing so submit a PR but I don’t know if there is a preference for one of the options.
Environment
NX version 11.5.2
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
By overriding the webpack config and setting the
publicPath
.This issue has been automatically marked as stale because it hasn’t had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏