<< All versions

Skill v1.0.0

currentLLM-judged scan90/100
forinda/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_ROOT
clearAssetCache()
})

Red flags:

  • Hand-rolled process.env.NODE_ENV === 'production' ? join(__dirname, '../templates') : join(__dirname, 'templates') — exactly what the asset manager replaces.
  • keys: 'strip' setting in assetMap.<ns> when basenames may collide — silent last-walk-wins data loss. Default 'auto' keeps extensions only for colliding groups.
  • Non-default Vite outDir without mirroring in kick.config.ts — manifest writes at dist/.kickjs-assets.json but the resolver can't find it. Mirror via build.outDir.
  • Forgetting to re-run kick typegen after adding files — assets.mails.newTemplate is a tsc error even though the file ships. kick dev does this on-change; one-shot CI builds need kick build (or kick build:assets for manifest-only).
  • Same-name welcome.ejs + welcome/login.ejs — directory wins in the typed surface; the .ejs file still copies but isn't addressable.

Nuances:

  • Resolution pipeline (cached): KICK_ASSETS_ROOT env override > built manifest at build.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. Run kick build:assets to exercise the real glob engine.
All versions