Closed
Description
🐞 Bug report
Command (mark with an x
)
- [x] build
- [x] serve
Is this a regression?
No
Description
When i use a bundleName
like the following inside the angular.json
for the styles
array. The order of scripts generated in the index.html are in the wrong order.
angular.json
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/ng2/main.ts",
"polyfills": "src/ng2/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/ng2/favicon.ico",
"src/ng2/assets"
],
"styles": [
{ "input": "src/ng2/main.scss", "bundleName": "main" }
],
"scripts": [
"build/main-ng1.js"
]
},
Order of scripts in index.html
after running ng build
<script type="text/javascript" src="runtime.js"></script>
<script type="text/javascript" src="polyfills.js"></script>
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="scripts.js"></script>
The Problem is, that the main.js
get inserted before the scripts.js
and this will fail if you have some external dependency added via scripts.js
I have already digged into the implementation in @angular-devkit/build-angular/src/angular-cli-files/plugins/index-html-webpack-plugin.js
and found out that the problem is the bundle name main
which is added into the this._options.entrypoints
array before the scripts
entrypoint is added.
🔬 Minimal Reproduction
See example above
🌍 Your Environment
Angular CLI: 7.3.0
Node: 8.11.1
OS: darwin x64
Angular: 7.2.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, upgrade
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.12.1
@angular-devkit/build-angular 0.12.1
@angular-devkit/build-optimizer 0.12.1
@angular-devkit/build-webpack 0.12.1
@angular-devkit/core 7.2.1
@angular-devkit/schematics 7.3.0
@angular/cli 7.3.0
@ngtools/webpack 7.2.1
@schematics/angular 7.3.0
@schematics/update 0.13.0
rxjs 6.3.3
typescript 3.2.2
webpack 4.23.1