Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
h657070128 opened this issue Sep 8, 2017 · 6 comments · Fixed by #7634

Comments

@h657070128
Copy link

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!

@mgpeter
Copy link

mgpeter commented Sep 8, 2017

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

@rvandehei
Copy link

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

@hansl
Copy link
Contributor

hansl commented Sep 8, 2017

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

@hansl
Copy link
Contributor

hansl commented Sep 8, 2017

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

@AlexOliinyk1
Copy link

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

image

dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this issue Apr 23, 2018
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants