angular-spartan-gotchas
Angular + Spartan UI (shadcn-for-Angular) + Tailwind v4 migration and build gotchas. Covers the non-obvious failure modes from installing Spartan 1.1.1 on Angular 21: the @spartan-ng/helm npm 404 workaround (manual copy + tsconfig paths), the @spartan-ng/cli:ui generator hang, the @theme inline Sass-stripping bug that kills Tailwind colors, production build-budget errors, and headless verification patterns. Use when scaffolding, migrating, or debugging a SpartAN + Tailwind Angular app.
- License 许可
- MIT
- 最近更新
- 2026-10-14
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- angular-spartan-gotchas
- tags
- [ "angular", "spartan", "tailwind", "migration", "troubleshooting" ]
- globs
- [ "**/styles.scss", "**/angular.json", "**/tsconfig.json", "**/*.component.ts" ]
- license
- MIT
- description
- Angular + Spartan UI (shadcn-for-Angular) + Tailwind v4 migration and build gotchas. Covers the non-obvious failure modes from installing Spartan 1.1.1 on Angular 21: the @spartan-ng/helm npm 404 workaround (manual copy + tsconfig paths), the @spartan-ng/cli:ui generator hang, the @theme inline Sass-stripping bug that kills Tailwind colors, production build-budget errors, and headless verification patterns. Use when scaffolding, migrating, or debugging a SpartAN + Tailwind Angular app.
02 资源文件 1
- 参考文档references/workflow-gotchas.md5.3 KB
03 SKILL.md 正文
Angular + Spartan UI + Tailwind v4 — Gotchas & Verified Workarounds
Condensed from a real Angular 21 + Spartan 1.1.1 + Tailwind v4 migration (July 2026). Each item below is a failure mode that actually happened and the fix that worked.
Install (Angular 21 + Spartan 1.1.1 + Tailwind v4)
npm install -D @spartan-ng/clithenng g @spartan-ng/cli:init --theme neutral.- If init fails on peer/Angular-version, upgrade Angular first (
ng update). Spartan 1.1.1 requires Angular >= 21. - After init,
styles.scsshas duplicated@useimports + an@theme inlineblock — clean it (see GOTCHA 3).
GOTCHA 1 — @spartan-ng/helm is NOT on npm (404)
Published packages: @spartan-ng/brain and @spartan-ng/cli. Helm sources ship INSIDE the CLI at
node_modules/@spartan-ng/cli/src/generators/ui/libs/<component>/files/.
Workaround — manual copy + tsconfig path mapping:
- Copy each component dir from CLI
libs/<c>/files/intosrc/app/ui/<c>(button, card, input, label, field, badge, spinner, separator, sonner, typography, utils). tsconfig.json:"baseUrl": ".","paths": { "@spartan-ng/helm": ["src/app/ui"], "@spartan-ng/helm/*": ["src/app/ui/*"] }npm install class-variance-authority clsx @ng-icons/core @ng-icons/lucide --legacy-peer-deps- Clean the barrel
src/app/ui/index.ts(remove exports for uncopied modules like./icon).
GOTCHA 2 — ng g @spartan-ng/cli:ui generator HANGS
It runs installPeerDependencies (npm install) and hangs on constrained hosts. Do NOT use the
generator; use the manual copy from GOTCHA 1. The ui-theme generator also hangs for the same reason
(the variant theme layer it would emit must be hand-written — see GOTCHA 3).
GOTCHA 3 — @theme inline in .scss is STRIPPED by Sass
Tailwind v4 + Sass strips @theme inline { } from .scss, so NO color utilities are generated.
Symptom: transparent backgrounds, unstyled (orange Material) buttons, dist CSS has no .bg-primary.
Fix — do NOT use @theme inside .scss:
- Raw palette as CSS custom properties under
:root(e.g.--background: 222 41% 11%;for #051424). @layer components { .bg-primary { background-color: hsl(var(--primary)); } .bg-background { ... } .text-foreground { ... } .text-muted-foreground { ... } .bg-border { ... } .border-border { ... } .text-primary { ... } }- Map SpartAN
cvavariant marker classes (CUSTOM classes, not utilities) in the same@layer components:.spartan-button-variant-default { background-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }plus-outline/-secondary/-ghost/-destructive/-linkand sizes-sm/-md/-lg;.spartan-badge-variant-default/secondary/destructive/outlinesimilarly. NOTE:spartan-buttonmarker class will NOT appear as a selector in dist CSS — EXPECTED. Verify by grepping dist for.bg-primary { background-color: hsl(var(--primary)); }.
Verification (headless — Playwright at /home/deeone/node_modules/playwright)
npx ng serve --port 4200as a BACKGROUND process. If "Port 4200 in use", a STALEng servefrom a prior session is running —ss -tlnp | grep 4200→kill -9 <pid>→ start fresh. A stale server serving an OLD build is the #1 cause of "blank screen / broken styles" false alarms.- Assert computed colors, not just "no errors":
getComputedStyle(document.body).backgroundColor→ expectrgb(5, 20, 36)for #051424 dark theme. - LSP tsc errors for
@spartan-ng/helm/*are often STALE; trustnpx ng build(respects tsconfig paths).
Production build-budget pitfall
npx ng build (no --configuration) enforces budgets. Legacy Material *.scss exceeds default 8kB
component-style error and 500kB initial error → BUILD=1. Fix angular.json: anyComponentStyle error
→ 20kB, initial error → 2MB. Dev build (--configuration development) skips budgets.
Angular control-flow & binding pitfalls
@fortrackmust be UNIQUE. Duplicate data → NG0955; usetrack $index.(keydown.enter)="$event.shiftKey ..."fails ($event typed Event). UseonEnter($event: KeyboardEvent)+onEnter($any($event)).- Parent rendering child via
<router-outlet>must NOT import the child (e.g. SearchPage must not import SearchInterface) → NG8113.
API calls from Angular (absolute base URL)
api.config.tsholds ABSOLUTE base URL (http://localhost:3000/api). Dev server does NOT proxy /api. Relative/api/...fetch hits :4200 → 404. Always useAPI_CONFIG.baseUrl.- CORS on NestJS agent controller is
Access-Control-Allow-Origin: *→ cross-origin fetch works. - AG-UI SSE: POST
{messages:[{role:'user',content}]}→res.body.getReader()→ split on\n\n→ parsedata: {json}→ accumulateTEXT_MESSAGE_CONTENT.deltainto a Subject<string>.
Stitch 1-to-1 workflow (user mandate pattern)
- Use REAL copied Helm components (hlmBtn/hlmCard/hlmInput/hlmLabel/hlmBadge/hlmSpinner/hlmSeparator), do NOT hand-roll Tailwind buttons. Stitch PNGs/JSON are SOURCE OF TRUTH for colors/type.
- For controls with no SpartAN equivalent (mat-select, mat-slide-toggle, mat-menu, mat-autocomplete, mat-chip, quill, mat-tab-group, mat-snack-bar, mat-dialog, mat-paginator, mat-nav-list/mat-expansion): RETAIN the Material module as functional control, convert visible chrome to SpartAN. Hybrid is accepted.
See references/workflow-gotchas.md for the full copy-paste code blocks and the verified SSE snippet.
04 同仓库更多 Skills
blocked-page-recovery
Use when a fetch fails: 403/429, paywall, WAF, bot wall.
gemini-vision-fallback
Vision fallback: Gemini REST API if vision_analyze blocked.
twitter-cli
Use twitter-cli for ALL Twitter/X operations — reading tweets, posting, replying, quoting, liking, retweeting, following, searching, user lookups. Invoke whenever user requests any Twitter interaction.
prism-scan
Structural analysis through dynamically generated cognitive lenses. Generates the optimal analytical lens for the specific code/artifact, then executes it. Finds conservation laws, structural invariants, and concrete bugs that vanilla analysis misses. Use on any code file, system design, or text artifact.
prism-reflect
Constraint transparency: analyzes an artifact structurally, then analyzes what its own analysis concealed. Produces a conservation law AND a constraint report showing what was maximized, what was sacrificed, and what to investigate next. The only AI skill that knows what it can't see.
prism-full
Full Prism: multi-pass structural analysis with mandatory adversarial self-correction. Designs custom analytical passes, executes them with chaining, then attacks its own findings before synthesizing. Use for maximum depth on important code or artifacts.