angular / angular

Deliver web apps with confidence 🚀
https://angular.dev
MIT License
95.97k stars 25.36k forks source link

ESBuild (build-angular:application) with ng build --base-href not working as expected #56523

Closed jmtt89 closed 3 months ago

jmtt89 commented 3 months ago

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

when use @angular-devkit/build-angular:application with cli argumemt "base-href" the generated index.html not include the path on scripts / styles links

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 17.3.8
Node: 20.11.1
Package Manager: npm 10.2.4
OS: linux x64

Angular: 17.3.11
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1703.8
@angular-devkit/build-angular   17.3.8
@angular-devkit/core            17.3.8
@angular-devkit/schematics      17.3.8
@angular/cli                    17.3.8
@schematics/angular             17.3.8
rxjs                            7.8.1
typescript                      5.4.5
zone.js                         0.14.7

Anything else?

generate the app

$> ng new demo-angular
? Which stylesheet format would you like to use? Sass (SCSS)     [ https://sass-lang.com/documentation/syntax#scss                ]
? Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? No
CREATE demo-angular/README.md (1065 bytes)
CREATE demo-angular/.editorconfig (274 bytes)
CREATE demo-angular/.gitignore (587 bytes)
CREATE demo-angular/angular.json (2796 bytes)
CREATE demo-angular/package.json (1043 bytes)
CREATE demo-angular/tsconfig.json (857 bytes)
CREATE demo-angular/tsconfig.app.json (263 bytes)
CREATE demo-angular/tsconfig.spec.json (273 bytes)
CREATE demo-angular/.vscode/extensions.json (130 bytes)
CREATE demo-angular/.vscode/launch.json (470 bytes)
CREATE demo-angular/.vscode/tasks.json (938 bytes)
CREATE demo-angular/src/main.ts (250 bytes)
CREATE demo-angular/src/favicon.ico (15086 bytes)
CREATE demo-angular/src/index.html (297 bytes)
CREATE demo-angular/src/styles.scss (80 bytes)
CREATE demo-angular/src/app/app.component.scss (0 bytes)
CREATE demo-angular/src/app/app.component.html (19903 bytes)
CREATE demo-angular/src/app/app.component.spec.ts (934 bytes)
CREATE demo-angular/src/app/app.component.ts (309 bytes)
CREATE demo-angular/src/app/app.config.ts (227 bytes)
CREATE demo-angular/src/app/app.routes.ts (77 bytes)
CREATE demo-angular/src/assets/.gitkeep (0 bytes)
⠴ Installing packages (npm)...                                                                                          ⠦ Installing packages (npm)...                                                                                      ✔ Packages installed successfully.
    Successfully initialized git.

executed command

$> ng build --base-href=/demo/
Initial chunk files   | Names         |  Raw size | Estimated transfer size
main-DJOLY6CB.js      | main          | 193.28 kB |                52.55 kB
polyfills-6EAL64PA.js | polyfills     |  33.43 kB |                10.87 kB
styles-5INURTSO.css   | styles        |   0 bytes |                 0 bytes

                      | Initial total | 226.71 kB |                63.42 kB

Output location: ..../demo-angular/dist/demo-angular

Application bundle generation complete. [16.613 seconds]

generated index.html

<!doctype html>
<html lang="en" data-critters-container>
<head>
  <meta charset="utf-8">
  <title>DemoAngular</title>
  <base href="/demo/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles-5INURTSO.css"></head>
<body>
  <app-root></app-root>
<script src="polyfills-6EAL64PA.js" type="module"></script><script src="main-DJOLY6CB.js" type="module"></script></body>
</html>

in index.html the <base href="/demo/"> is correctly setted but the script and style does not include in the path...

JoostK commented 3 months ago

This does seem expected; the script and style tags use a relative path and are therefore relative to the base href already, so there is no need to make them absolute paths including the base href.

Are you seeing issues otherwise?

Closing for now as I believe this is working as expected, feel free to follow up though.

angular-automatic-lock-bot[bot] commented 2 months ago

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.