Skip to content

scripts path in index.html does not follow deployUrl defined in .angular-cli.json in 1.4.0 #7628

Description

@h657070128

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.4.0
node: 8.0.0
os: darwin x64
@angular/animations: 4.3.6
@angular/common: 4.3.6
@angular/compiler: 4.3.6
@angular/core: 4.3.6
@angular/forms: 4.3.6
@angular/http: 4.3.6
@angular/platform-browser: 4.3.6
@angular/platform-browser-dynamic: 4.3.6
@angular/router: 4.3.6
@angular/cli: 1.3.2
@angular/compiler-cli: 4.3.6
@angular/language-service: 4.3.6

Repro steps.

.angular-cli.json: (Note the deployUrl)

"apps": [
    {
      "root": "src",
      "outDir": "target/my-app",
      "deployUrl": "my-app",
      "assets": [],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "tsconfig": "tsconfig.app.json",
      "styles": [
        "styles.css"
      ],
      "scripts": [
        "../node_modules/some-libs/file.js",
      ]
    }
  ]

After I run ng build --prod, the index.html in target/my-app:

...
<body>
    <my-app></my-app>
    <script type="text/javascript" src="my-app/inline.6cca322f7e258972d83b.bundle.js"></script>
    <script type="text/javascript" src="my-app/polyfills.1f88e2c5c51b2654c108.bundle.js"></script>
    <script type="text/javascript" src="scripts.4b3dfabee60e0d1b2077.bundle.js"></script>
    <script type="text/javascript" src="my-app/vendor.7e4452b3f0246d32e944.bundle.js"></script>
    <script type="text/javascript" src="my-app/main.4f222f38a3c2a53f4f40.bundle.js"></script>
</body>
...

Note the scripts path is not under my-app, but the the scripts file is under my-app directory. As a result, scripts cannot be fount in browser.

1.3.2 does not have this problem.
Thanks!

Activity

  1. mgpeter commented on Sep 8, 2017

    @mgpeter

    Same issue here.

    Versions:

    @angular/cli: 1.4.0
    node: 6.11.2
    os: win32 x64
    @angular/animations: 4.3.6
    @angular/common: 4.3.6
    @angular/compiler: 4.3.6
    @angular/core: 4.3.5
    @angular/forms: 4.3.6
    @angular/http: 4.3.6
    @angular/platform-browser: 4.3.6
    @angular/platform-browser-dynamic: 4.3.6
    @angular/router: 4.3.6
    @angular/cli: 1.4.0
    @angular/compiler-cli: 4.3.6
    @angular/language-service: 4.3.6
    @angular/platform-server: 4.3.6
    typescript: 2.4.2
    

    Repro:
    .angular-cli.json:

    "apps": [
    
            {
                "root": "src",
                "outDir": "dist",
                "assets": [
                    "assets",
                    "favicon.ico"
    
    
                ],
                "index": "index.html",
                "main": "main.ts",
                "polyfills": "polyfills.ts",
                "test": "test.ts",
                "tsconfig": "tsconfig.app.json",
                "testTsconfig": "tsconfig.spec.json",
                "prefix": "app",
                "styles": [
                    "assets/styles/jquery.bxslider.css",
                    "assets/styles/main.scss"
                ],
                "scripts": [
                    "assets/scripts_include/jquery-1.11.3.min.js",
                    "assets/scripts_include/jquery-ui.min.js",
                    "assets/scripts_include/jquery.ui.touch-punch.min.js",
                    "assets/scripts_include/jquery.bxslider.min.js"
                ],
                "environmentSource": "environments/environment.ts",
                "environments": {
                    "dev": "environments/environment.ts",
                    "prod": "environments/environment.prod.ts",
                    "qa": "environments/environment.qa.ts",
                    "uat": "environments/environment.uat.ts"
                }
            }
    ]
    

    Running ng build --dev --environment=dev --deploy-url=/dist/ -sm results in index.html with botched scripts file reference:

        <script type="text/javascript" src="/dist/inline.bundle.js"></script>
        <script type="text/javascript" src="/dist/polyfills.bundle.js"></script>
        <script type="text/javascript" src="scripts.bundle.js"></script>
        <script type="text/javascript" src="/dist/styles.bundle.js"></script>
        <script type="text/javascript" src="/dist/vendor.bundle.js"></script>
        <script type="text/javascript" src="/dist/main.bundle.js"></script>
    

    Workaround for now is to fix the path manually, but it is a small issue during development.

    Additional info:
    I haven't had a chance to investigate properly, but I'm somewhat sure the issue was introduced within e8f27f0 , see the new logic for globalScriptsByEntry reduce in packages/@angular/cli/models/webpack-configs/common.ts and the new logic in packages/@angular/cli/plugins/insert-concat-assets-webpack-plugin.ts

  2. rvandehei commented on Sep 8, 2017

    @rvandehei

    same here. How soon do they normally fix these sort of bugs? This was an untimely release for us.

  3. hansl commented on Sep 8, 2017

    @hansl
    Contributor

    We should fix this one ASAP. I'm investigating and will try to do an emergency release today.

  4. added 2 commits that reference this issue on Sep 8, 2017
    31276bc
    de43901
  5. added 2 commits that reference this issue on Sep 8, 2017
    e0a70a3
    e6f3841
  6. hansl commented on Sep 8, 2017

    @hansl
    Contributor

    This has been released in 1.4.1. Try it out and if there's a problem, open another issue please.

  7. AlexOliinyk1 commented on Sep 13, 2017

    @AlexOliinyk1

    @hansl updated to 1.4.1
    but my problem still looks like this wrong path

    image

  8. added a commit that references this issue on Apr 23, 2018
    861cc1c
  9. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  10. locked and limited conversation to collaborators on Sep 8, 2019
  11. added a commit that references this issue on May 29, 2026
    23766bd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions