15

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

3
  • you need the index.html file as it contains the meta data and bits Commented Aug 14, 2018 at 12:39
  • @Aerus, I'm afraid you must to investigate and modify someway the file index-html-webpack-plugin.js from node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins or another like Commented Aug 14, 2018 at 12:55
  • 1
    It's a mild annoyance, but I too don't need the index page as my project is used only to build custom elements. It feels like being able to remove the index page should be an option for these types of scenarios. Commented Apr 26, 2020 at 6:55

2 Answers 2

18

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I wasted so many time trying to solve the index.html issue, but that's true, I don't need it in the build, in prod app is loaded in another page. This is a wonderful workaround, thanks @nebirhos
2

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"
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.