`ng generate application` produces a missing stylesheet when a workspace component type is configured
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- angular, typescript
- 领域
- build-system, cli
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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!
- 主要语言
- TypeScript
- 星标
- 27k
- 派生
- 11.8k
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 271
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
angular/angular-cli 的其他 Issue
-
Font inlining cache is not created or reused可能已有人在做 @nagahara-naoki 今天认领。 未关闭area: @angular/build
难度 2/5 1-3 小时 新手友好度 82/100
angular/angular-cli#34719 ·
维护者通常 1 天内回复
-
area: @angular/cli
难度 3/5 半天 新手友好度 42/100
angular/angular-cli#34716 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 72/100
angular/angular-cli#34688 ·
维护者通常 1 天内回复
-
area: @angular/build
难度 4/5 3-5 天 新手友好度 55/100
angular/angular-cli#34674 · 2 条评论 ·
维护者通常 1 天内回复
-
Tailwind CSS v4 classes in new or moved files are not picked up by ng serve until another rebuild可能重新可做 关联的 PR 已关闭且未合并。 未关闭area: @angular/build
难度 4/5 3-5 天 新手友好度 35/100
angular/angular-cli#34446 ·
维护者通常 1 天内回复
查看 angular/angular-cli 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
OHDSI/Data2Evidence#3693 ·
维护者通常 3 天内回复
-
severity:low triage:confirmed
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
bug package:workers-shared
难度 2/5 1-3 小时 新手友好度 72/100
cloudflare/workers-sdk#16924 · 1 条评论 ·
维护者通常 1 天内回复
-
bug frontend priority: low
难度 2/5 1-3 小时 新手友好度 82/100
nooriegarg/ContribIQ#74 ·
维护者通常 1 天内回复
-
parse: child keys like `007`, `1e3`, `0x1f`, `-1` make the parent an empty array and hide the value未关闭
难度 2/5 1-3 小时 新手友好度 78/100