Skip to content

Scripts.bundle.js deploy-url wrongly prefixed when deviating from standard project structure #8127

@ArnaudHambenne

Description

@ArnaudHambenne

Bug Report or Feature Request (mark with an x)

- [X] bug report -> please search issues before submitting - [ ] feature request 

Versions.

@angular/cli: 1.4.3
node: 6.11.3
os: darwin x64

Repro steps.

SETUP:
$ ng new scripts-test
$ npm install --save bootstrap

--> Move src/main.ts to src/app/main.ts, and update the reference in .angular-cli.json accordingly:
FROM:
"main": "main.ts",
TO:
"main": "app/main.ts",

--> Move src/index.html to src/app/index.html, and update the reference in .angular-cli.json accordingly:
FROM:
"index": "index.html",
TO:
"index": "app/index.html",

--> Update import urls in src/app/main.ts
FROM:
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
TO:
import { AppModule } from './app.module';
import { environment } from './../environments/environment';

--> add to scripts array in .angular-cli.json the line "../node_modules/bootstrap/dist/js/bootstrap.js"
FROM:
"scripts": [],
TO:
"scripts": ["../node_modules/bootstrap/dist/js/bootstrap.js"],

--> Build the project with deploy-url
$ ng build --deploy-url /app

Desired functionality.

I would like to see some form of consistency within the url building for the bundles. As shown below, every bundles gets prefixed correctly with the deploy-url, except for the scripts bundle.

Result within index.html:

<script type="text/javascript" src="/app/inline.bundle.js"></script><script type="text/javascript" src="/app/polyfills.bundle.js"></script>

<script type="text/javascript" src="/app/../scripts.bundle.js"></script>

<script type="text/javascript" src="/app/styles.bundle.js"></script><script type="text/javascript" src="/app/vendor.bundle.js"></script><script type="text/javascript" src="/app/main.bundle.js"></script>

Mention any other details that might be useful.

I am using the Angular CLI for a multi-page application (technically hybrid), where I want to encapsulate each separate page in a folder within the /src folder. When I build my application with a specified --deploy-url flag, all urls for the bundles within the index page get built correctly, except for the scripts bundle. This one gets prefixed with "../" before being prepended with the deploy-url, rendering the package unreachable when loading the html in a web browser.

Metadata

Metadata

Assignees

Labels

P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfulseverity5: regressiontype: bug/fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions