Angular build fails to resolve CSS when package is externalized

Offen
#30,412 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
angular, bootstrap, sass
Bereich
build-system

Rechercherichtung

Beginne mit der verknüpften minimalen Reproduktion, insbesondere mit angular.json und src/styles.scss, und führe ng build aus, wobei bootstrap in externalDependencies aufgeführt ist. Verfolge, wie externalisierte Abhängigkeiten während des Angular-Sass-/Global-Styles-Builds behandelt werden; als abgeschlossen gilt die Aufgabe, wenn JavaScript extern bleibt und bootstrap/scss/bootstrap erfolgreich aufgelöst wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

angular/build:application area: @angular/build freq1: low severity3: broken
Which @angular/* package(s) are the source of the bug?

compiler

Is this a regression?

No

Description

Hi there 👋

In a micro-frontend architecture, our goal is to compile CSS utilities while relying on importmap to load all JavaScript. I'm not sure if I’ve missed a configuration step or if this is expected behavior.

However, in the Vite ecosystem, when using the option to externalize dependencies, all the CSS is correctly resolved, but the JavaScript is excluded from the import.

export default defineConfig((env) => {
  return {
    build: {
      rollupOptions: {
        external: ["bootstrap"],
      },
    },
});

However, in the Angular environment, this approach causes the build to fail because it can't locate the CSS.

  "projects": {
    "test-angular": {
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:application",
          "options": {
            "externalDependencies": ["bootstrap"],

To isolate the issue, I created a minimal reproduction using Bootstrap.

Thank you very much for the awesome work 🚀

Please provide a link to a minimal reproduction of the bug

https://github.com/Tragio/angular-externalize-repro

Please provide the exception or error you saw
> ng build

Application bundle generation failed. [1.968 seconds]

✘ [ERROR] Can't find stylesheet to import.
  ╷
2 │ @use "bootstrap/scss/bootstrap";
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  src/styles.scss 2:1  root stylesheet [plugin angular-sass]

    angular:styles/global:styles:1:8:
      1 │ @import 'src/styles.scss';
        ╵         ~~~~~~~~~~~~~~~~~
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 19.2.14
Node: 22.14.0
Package Manager: npm 10.9.2
OS: darwin arm64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.14
@angular-devkit/build-angular   19.2.14
@angular-devkit/core            19.2.14
@angular-devkit/schematics      19.2.14
@schematics/angular             19.2.14
rxjs                            7.8.2
typescript                      5.7.3
zone.js                         0.15.1
Anything else?

No response

Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
16 Std. 35 Min.
Gemergte PRs (30 T.)
176

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus angular/angular-cli

Alle Issues in angular/angular-cli

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.