All our Angular applications are bootstrapped in other applications (.jsp
files which load the javascript files and include the <app-root>
tag), so we have no need for an index.html
**.
However when I remove the index
property from our angular.json
it gives me the error:
Data path "" should have required property 'index'.
If I leave it empty it does build but I get the error:
...
95% emitting index-html-webpack-pluginEISDIR: illegal operation on a directory, read
Error: EISDIR: illegal operation on a directory, read
How can I perform an ng build
without the index.html
?
** our deploy process now actually copies the index.html
to our CDN which is unwanted since we don't want to serve these files to the end users at all, the index.html
is only used for developers during ng serve
html file. Angular is a framework which allows us to create "Single Page Applications", and here the index. html is the single page which was provided by the server.
Customize Webpack Configuration in Your Angular Application Now that we've added it to our project, we can use the index transform option to modify the HTML file output, based on the environment.
–output-hashing all — hash contents of the generated files and append hash to the file name to facilitate browser cache busting (any change to file content will result in different hash and hence browser is forced to load a new version of the file)
We will start by setting up the module loader, then use npm to install Angular and its dependencies, as well as some tools and polyfills we will need, such as the TypeScript compiler. Finally, we will create a minimal application skeleton, and write the code for bootstrapping it.
In case anyone is still having the same issue, this is how I solved it.
In your angular.json
:
"architect": {
"build": {
...
"configurations": {
"production": {
"index": "", // Do not copy index.html
...
ng build --prod
will not copy the HTML file, while ng build
and ng serve
will keep using it as expected.
You can concatenate commands in the scripts
section of package.json
. So append a delete command and create something like this (Windows command; adapt it to your system):
"scripts": {
"build prod": "ng build --prod --env=prod -op dist && del dist\\index.html"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With