<< All versions
Skill v1.0.0
currentLLM-judged scan90/100forinda/kick-fullstack-netlify/use-asset-manager
──Details
PublishedOctober 21, 2026 at 11:35 AM
Content Hashsha256:13a96d84281f4fd5...
Git SHA750c3b391b33
──Files
Files (1 file, 2.7 KB)
SKILL.md2.7 KBactive
SKILL.md · 65 lines · 2.7 KB
version: "1.0.0" name: kickjs-use-asset-manager description: Use when code reads template files / JSON fixtures via fs.readFile + path arithmetic — switch to assets.<ns>.<key>() and the kick.config.ts assetMap.
<!-- Generated by kick g agents for kick-fullstack-server. Edits are overwritten on the next refresh; keep customisation in a SKILL.local.md alongside. -->
Configure kick.config.ts:
ts
export default defineConfig({assetMap: {mails: { src: 'src/templates/mails' },reports: { src: 'src/templates/reports', glob: '**/*.{ejs,html}' },},})
Consume via the typed Proxy — no __dirname arithmetic, dev/prod paths handled:
ts
import { assets } from '@forinda/kickjs'const html = await assets.mails.welcome() // typed: tsc errors on bad key
Class-field decorator (lazy getter, swappable in tests):
ts
class WelcomeMailService {@Asset('mails/welcome') private welcomeTemplate!: () => Promise<string>async send(to: string) {const body = await this.welcomeTemplate()}}
Dynamic dispatch (CMS templates, codegen) — resolveAsset(ns, key) throws UnknownAssetError with { namespace, key } fields when the key is missing.
Test fixtures — swap via env override + cache clear:
ts
beforeEach(() => {process.env.KICK_ASSETS_ROOT = path.resolve('__fixtures__/assets')clearAssetCache()})afterEach(() => {delete process.env.KICK_ASSETS_ROOTclearAssetCache()})
Red flags:
- Hand-rolled
process.env.NODE_ENV === 'production' ? join(__dirname, '../templates') : join(__dirname, 'templates')— exactly what the asset manager replaces. keys: 'strip'setting inassetMap.<ns>when basenames may collide — silent last-walk-wins data loss. Default'auto'keeps extensions only for colliding groups.- Non-default Vite
outDirwithout mirroring inkick.config.ts— manifest writes atdist/.kickjs-assets.jsonbut the resolver can't find it. Mirror viabuild.outDir. - Forgetting to re-run
kick typegenafter adding files —assets.mails.newTemplateis a tsc error even though the file ships.kick devdoes this on-change; one-shot CI builds needkick build(orkick build:assetsfor manifest-only). - Same-name
welcome.ejs+welcome/login.ejs— directory wins in the typed surface; the.ejsfile still copies but isn't addressable.
Nuances:
- Resolution pipeline (cached):
KICK_ASSETS_ROOTenv override > built manifest atbuild.outDir/dist/build/out> dev-fallback in-memory walk. Manifest presence = "running from built dist." - Dev-mode glob matcher is a lite implementation —
**/*,**/*.ext,**/*.{a,b}are guaranteed; exotic globs warn-once and accept everything. Runkick build:assetsto exercise the real glob engine.