bostonjava
bostonjava

Reputation: 664

ng build generating different outputs

All,

I need to deploy two angular project. Both builds fine locally and displays the index page. When I deploy to kubernetes, one application complains that it can't find runtime.js, polyfills.js, styles.js, vendor.js and main.js, while the other application works fine.

I looked into the /dist folder of both application. The application that works has the following in /dist folder. main.js polyfills.js runtime.js scripts.js vendor.js

Application that fails has the following files

main-es2015.js main-es5.js polyfills-es2015.js polyfills-es5.js runtime-es2015.js runtime-es5.js styles-es2015.js styles-es5.js vendor-es2015.js vendor-es5.js

I have couple of questions

  1. Why ng build generated different file. I read number of posts. It seems ng build --watch generated different files compared to ng build. But I am not using ng build --watch.
  2. Why my application with es5 and es2015 worked locally but when deployed to kubernetes failed?

I am using following angular version

Angular CLI: 11.1.4 Node: 12.22.1

Any clue will be highly appreciated!

Upvotes: 1

Views: 2639

Answers (2)

Bo Vandersteene
Bo Vandersteene

Reputation: 94

I think you need a serve-path. If this is not provided, the application will look to the root of your application.

f.e.

  • my.website.com/test needs the --serve-path=test
  • my.website.com don't need a serve-path

More information can be found on https://angular.io/cli/serve

Upvotes: 0

Chris W.
Chris W.

Reputation: 23280

In the project creating the -2015, -es5 bundle files you're invoking differential loading meaning that in the browserslist file you're likely supporting an older browser, and in your tsconfig.json file in the compilerOptions your target is probably es2015 (aka es6) but the compiler thinks it needs to support older es5 browsers like IE. So it generates bundles accordingly to support both es2015 (aka es6) as well as es5.

As for the specifics of your deployment issues, well would probably need more details in your process there but hope this helps. Cheers

Upvotes: 1

Related Questions