`ng generate application` produces a missing stylesheet when a workspace component type is configured
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- angular, typescript
- Lĩnh vực
- build-system, cli
Hướng nghiên cứu
Start with the application schematic and its root component templates, especially the handling of component type for the 2016 and 2025 naming styles. Reproduce with the workspace-level component default and the commands in the issue, then run the application schematic’s E2E test for this case. Done means generated root component files and stylesheet references match the 2025 names and the build succeeds; the workspace default still applies to separately generated components.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi Angular team!
I found a case where a newly generated application fails to build when the workspace has a default component type configured.
Command
generate, build
Description
With "@schematics/angular:component": { "type": "component" } in the workspace-level schematics section of angular.json, generating an application with the 2025 file naming style produces app.component.css, but the generated app.ts references ./app.css.
As a result, the application fails its first build with NG2008. Both app.ts and an extra app.component.ts are generated.
Minimal Reproduction
-
Create a workspace:
ng new component-type-repro --create-application=false --defaults --package-manager=npm --skip-git cd component-type-repro -
Add the following at the top level of
angular.json(alongsideprojects):"schematics": { "@schematics/angular:component": { "type": "component" } } -
Generate and build an application:
ng generate application demo --file-name-style-guide=2025 --style=css --ssr=false --skip-install ng build demo --configuration=development
Actual behavior
The generated files include:
projects/demo/src/app/app.ts
projects/demo/src/app/app.component.ts
projects/demo/src/app/app.component.css
There is no app.css, but app.ts contains:
styleUrl: './app.css',
Expected behavior
The root component files and their references should consistently follow the selected application naming style: app.ts, app.html, and app.css for 2025. The generated application should build successfully.
The workspace component default should still apply when generating ordinary components separately.
Exception or Error
✘ [ERROR] NG2008: Could not find stylesheet file './app.css'. [plugin angular-compiler]
projects/demo/src/app/app.ts:7:12:
7 │ styleUrl: './app.css',
╵ ~~~~~~~~~~~
Your Environment
Reproduced with the locally built CLI from main at d5035923f0e357b2526c98110125eee04b05192f, using the repository's Bazel E2E runner. Its ng version output reports:
Angular CLI : 22.3.0-next.5
Angular : 22.3.0-next.4
Node.js : 24.15.0
Package Manager : npm 12.0.2
Operating System : darwin x64
I have not established the last working version.
Anything else relevant?
- #31053 introduced the file naming style option and describes the 2025 root component filename as
app.ts. - #34450 and #34472 addressed similar inheritance of the workspace component
typein the app-shell and routed-module schematics. This report concerns the application schematic.
The application schematic explicitly sets the component type for the 2016 style, but leaves it unspecified for 2025. It appears that the workspace default is inherited during component generation while the application templates continue to use the 2025 filenames.
I have a local fix and an E2E regression test for this case and will follow up with a PR. Thanks for taking a look!
- Ngôn ngữ chính
- TypeScript
- Star
- 27k
- Fork
- 11.8k
- Merge trung bình
- 1 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 271
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của angular/angular-cli
-
Font inlining cache is not created or reusedCó thể đã có người làm @nagahara-naoki đã nhận hôm nay. Đang mởarea: @angular/build
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
angular/angular-cli#34719 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: @angular/cli
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 42/100
angular/angular-cli#34716 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
angular/angular-cli#34688 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: @angular/build
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
angular/angular-cli#34674 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Tailwind CSS v4 classes in new or moved files are not picked up by ng serve until another rebuildCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởarea: @angular/build
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
angular/angular-cli#34446 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của angular/angular-cli
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
OHDSI/Data2Evidence#3693 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
severity:low triage:confirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Cotal-AI/Cotal#6803 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug package:workers-shared
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
cloudflare/workers-sdk#16924 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug frontend priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
nooriegarg/ContribIQ#74 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
parse: child keys like `007`, `1e3`, `0x1f`, `-1` make the parent an empty array and hide the valueĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100