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

Angular 17: dev-server with esbuild rewrites hrefs in index.html #27795

Open
1 task done
dprinz opened this issue Jun 6, 2024 · 0 comments
Open
1 task done

Angular 17: dev-server with esbuild rewrites hrefs in index.html #27795

dprinz opened this issue Jun 6, 2024 · 0 comments

Comments

@dprinz
Copy link

dprinz commented Jun 6, 2024

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

Angular 17 with webpack

Description

I use several angular apps and microfrontends and have proxy that routes each url to a different microfrontend.

With Angular 17 this does not work anymore, because the href entries in the index.html seem to be modified by the vite server.

I am using the following configuration of my dev-server in angular.json:

        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "servePath": "/microfrontend1"
          }
        }

In my index.html iinject a script which comes from a different microfrontend using an absolute path:
<script src="/microfrontend2/shared-components.js" defer></script>

The vite server renders this tag as
<script src="/microfrontend1/microfrontend2/shared-components.js" defer></script>

Vite seems to always append the servePath value to all hrefs, not regarding if they are relative or absolute.
There seems to be no possible option to disable this messing around with urls.

Minimal Reproduction

Setup new Angular 17 Project
Use esbuild
Add a <script /> tag with an absolute href to the index.html

Exception or Error

No response

Your Environment

@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
ng-packagr                      16.2.3
rxjs                            7.8.1
typescript                      5.3.2
webpack                         5.76.1
zone.js                         0.13.3

Anything else relevant?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants