Angular-cli: ng build --prod does not include index.html or assets folder

Created on 26 Jul 2019  路  10Comments  路  Source: angular/angular-cli

馃悶 Bug report

Command (mark with an x)


- [ ] new
- [ x ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?


Yes, the previous version in which this bug was not present was: ....

No, I was previously able to build the project successfully

Description

A clear and concise description of the problem...

"ng build --prod" produces only few files but does not add the index.html file in the "dist/projectxx" folder or any of the assets. When adding the "--watch" flag to the same command, all the files are created. I can upload this compiled output to Firebase hosting successfully, but I don't understand why I have to add the --watch flag.

馃敩 Minimal Reproduction

package.json:

{
"name": "ictvaardighedenscan",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~8.0.2",
"@angular/common": "~8.0.2",
"@angular/compiler": "~8.0.2",
"@angular/core": "~8.0.2",
"@angular/fire": "^5.2.1",
"@angular/forms": "~8.0.2",
"@angular/platform-browser": "~8.0.2",
"@angular/platform-browser-dynamic": "~8.0.2",
"@angular/router": "~8.0.2",
"@fortawesome/angular-fontawesome": "^0.4.0",
"@fortawesome/fontawesome-svg-core": "^1.2.18",
"@fortawesome/free-brands-svg-icons": "^5.8.2",
"@fortawesome/free-solid-svg-icons": "^5.8.2",
"@ngrx/store": "^7.4.0",
"angular-notifier": "^4.1.1",
"bulma": "^0.7.5",
"bulma-extensions": "^6.2.7",
"firebase": "^6.1.0",
"jspdf": "^1.5.3",
"moment": "^2.24.0",
"rxjs": "~6.5.2",
"survey-angular": "^1.1.1",
"survey-creator": "^1.1.1",
"survey-knockout": "^1.1.1",
"survey-pdf": "^1.1.1",
"surveyjs-widgets": "^1.1.1",
"tslib": "^1.9.0",
"zone.js": "git://github.com/JiaLiPassion/zone.js.git#dp-temp-dist"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.800.3",
"@angular/cli": "~8.0.3",
"@angular/compiler-cli": "~8.0.2",
"@angular/language-service": "~8.0.2",
"@types/node": "~8.9.4",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.4.5"
}
}

馃敟 Exception or Error





There is no error, the command "ng build --prod" does not fail but it just does not produce all necessary files to be able to deploy the app to production.

馃實 Your Environment




Angular CLI: 8.0.6
Node: 10.15.3
OS: darwin x64
Angular: 8.0.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.6
@angular-devkit/build-angular     0.800.6
@angular-devkit/build-optimizer   0.800.6
@angular-devkit/build-webpack     0.800.6
@angular-devkit/core              8.0.6
@angular-devkit/schematics        8.0.6
@angular/cli                      8.0.6
@angular/fire                     5.2.1
@ngtools/webpack                  8.0.6
@schematics/angular               8.0.6
@schematics/update                0.800.6
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.30.0

Anything else relevant?

The only thing I can remember as potential issue causing this, was adding the following in the tsconfig.json file:
skipLibCheck: true

then ran "ng build --prod"

This is when the issue appeared first. Then I removed the "skipLibCheck: true" again but it continued to behave unexpectedly.

repro steps

Most helpful comment

Hi @handihow,

I just had a look at this, and the reason why there is no index.html is because you have a build error.

chunk {0} runtime.465c2333d355155ec5f3.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.75e21011585255b0d6d3.js (main) 6.91 MB [initial] [rendered]
chunk {2} polyfills.ecd409d84f84d9492396.js (polyfills) 36.4 kB [initial] [rendered]
chunk {3} polyfills-es5.93893f560e403d23958a.js (polyfills-es5) 69.9 kB [initial] [rendered]
chunk {4} styles.dae070ff04eb4dfe1fc4.css (styles) 304 kB [initial] [rendered]
Date: 2019-08-01T10:47:43.127Z - Hash: c6b19bd4923f95b6a074 - Time: 403913ms

WARNING in budgets, maximum exceeded for initial. Budget 2 MB was exceeded by 5.32 MB.

ERROR in budgets, maximum exceeded for initial. Budget 5 MB was exceeded by 2.32 MB.

In order for the index to be generated the build needs to be successful.

All 10 comments

Hi, skipLibCheck is a TypeScript compiler option and is used to skip type checking of all declaration files *.d.ts. And doesn't effect asset emission.

Can you setup a minimal reproduction of the bug please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

馃悶 Bug report

Command (mark with an x)

- [ ] new
- [ x ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes, the previous version in which this bug was not present was: ....
No, I was previously able to build the project successfully

Description

A clear and concise description of the problem...
"ng build --prod" produces only few files but does not add the index.html file in the "dist/projectxx" folder or any of the assets. When adding the "--watch" flag to the same command, all the files are created. I can upload this compiled output to Firebase hosting successfully, but I don't understand why I have to add the --watch flag.

馃敩 Minimal Reproduction

package.json:

{
"name": "ictvaardighedenscan",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~8.0.2",
"@angular/common": "~8.0.2",
"@angular/compiler": "~8.0.2",
"@angular/core": "~8.0.2",
"@angular/fire": "^5.2.1",
"@angular/forms": "~8.0.2",
"@angular/platform-browser": "~8.0.2",
"@angular/platform-browser-dynamic": "~8.0.2",
"@angular/router": "~8.0.2",
"@fortawesome/angular-fontawesome": "^0.4.0",
"@fortawesome/fontawesome-svg-core": "^1.2.18",
"@fortawesome/free-brands-svg-icons": "^5.8.2",
"@fortawesome/free-solid-svg-icons": "^5.8.2",
"@ngrx/store": "^7.4.0",
"angular-notifier": "^4.1.1",
"bulma": "^0.7.5",
"bulma-extensions": "^6.2.7",
"firebase": "^6.1.0",
"jspdf": "^1.5.3",
"moment": "^2.24.0",
"rxjs": "~6.5.2",
"survey-angular": "^1.1.1",
"survey-creator": "^1.1.1",
"survey-knockout": "^1.1.1",
"survey-pdf": "^1.1.1",
"surveyjs-widgets": "^1.1.1",
"tslib": "^1.9.0",
"zone.js": "git://github.com/JiaLiPassion/zone.js.git#dp-temp-dist"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.800.3",
"@angular/cli": "~8.0.3",
"@angular/compiler-cli": "~8.0.2",
"@angular/language-service": "~8.0.2",
"@types/node": "~8.9.4",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.4.5"
}
}

馃敟 Exception or Error

There is no error, the command "ng build --prod" does not fail but it just does not produce all necessary files to be able to deploy the app to production.

馃實 Your Environment

Angular CLI: 8.0.6
Node: 10.15.3
OS: darwin x64
Angular: 8.0.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.6
@angular-devkit/build-angular     0.800.6
@angular-devkit/build-optimizer   0.800.6
@angular-devkit/build-webpack     0.800.6
@angular-devkit/core              8.0.6
@angular-devkit/schematics        8.0.6
@angular/cli                      8.0.6
@angular/fire                     5.2.1
@ngtools/webpack                  8.0.6
@schematics/angular               8.0.6
@schematics/update                0.800.6
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.30.0

Anything else relevant?

The only thing I can remember as potential issue causing this, was adding the following in the tsconfig.json file:
skipLibCheck: true

then ran "ng build --prod"

This is when the issue appeared first. Then I removed the "skipLibCheck: true" again but it continued to behave unexpectedly.

I had same issue

I had got this error after update to angular 8 .

Can anyone please help me for the same.

I have recreated my project step by step in the repro-app
This is the repo:
https://github.com/handihow/survey-repro-app

What I have found, is that the issue appears when I enable the SurveyPDF library. If you comment out the "savePDF" function in the survey component, it compiles including the "index.html" file when you build with "ng build --prod".

But if the function is included, and I assume then also the SurveyPDF library will be included in the build, then the build does not have the "index.html" file.

I have added two screenshots for clarification. On one screenshot, you can see I have the function enabled on the html and also in the ts file of the SurveyComponent. The index.html file is missing in the build. On the other screenshot, I have commented this part out, and the index.html file is in the production build.

Schermafbeelding 2019-08-01 om 12 15 40
Schermafbeelding 2019-08-01 om 12 21 41

I have opened a support ticket as well to the SurveyJS team and notified them about this issue. SurveyPDF is in beta, so they might identify an issue with the library.

Hi @handihow,

I just had a look at this, and the reason why there is no index.html is because you have a build error.

chunk {0} runtime.465c2333d355155ec5f3.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.75e21011585255b0d6d3.js (main) 6.91 MB [initial] [rendered]
chunk {2} polyfills.ecd409d84f84d9492396.js (polyfills) 36.4 kB [initial] [rendered]
chunk {3} polyfills-es5.93893f560e403d23958a.js (polyfills-es5) 69.9 kB [initial] [rendered]
chunk {4} styles.dae070ff04eb4dfe1fc4.css (styles) 304 kB [initial] [rendered]
Date: 2019-08-01T10:47:43.127Z - Hash: c6b19bd4923f95b6a074 - Time: 403913ms

WARNING in budgets, maximum exceeded for initial. Budget 2 MB was exceeded by 5.32 MB.

ERROR in budgets, maximum exceeded for initial. Budget 5 MB was exceeded by 2.32 MB.

In order for the index to be generated the build needs to be successful.

Hi Alan,

You are correct. Increasing the budgets allowed me to build without error.

Now I finished refactoring code so that the separate chunks are smaller. Basically I am now loading lazily the components using SurveyJS libraries and Components using Plotly.

I could actually set the default warning and error budgets back to 2MB and 5MB and the build is alright.

Many thanks

Roeland

Thank you @alan-agius4 it helps.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings