feat(build): add automatic npm dependency management

- Add deps:ensure-npm task to automatically install npm packages when needed
- Configure build, serve, and test tasks to depend on npm dependencies
- Use Task's sources/generates/status for intelligent dependency detection
- Prevents build failures due to missing PostCSS and other npm packages
- Improves developer experience by eliminating manual npm install steps
This commit is contained in:
Stephan Lo 2025-10-25 09:40:44 +02:00
parent eec679657b
commit 69457ec964

View file

@ -13,16 +13,22 @@ tasks:
# Build tasks
build:
desc: Build Hugo site
deps:
- deps:ensure-npm
cmds:
- "{{.HUGO_CMD}} --gc --minify"
build:dev:
desc: Build Hugo site for development
deps:
- deps:ensure-npm
cmds:
- "{{.HUGO_CMD}}"
serve:
desc: Start Hugo dev server
deps:
- deps:ensure-npm
cmds:
- "{{.HUGO_CMD}} server"
@ -48,16 +54,22 @@ tasks:
test:build:
desc: Test Hugo build
deps:
- deps:ensure-npm
cmds:
- "{{.HUGO_CMD}} --gc --minify --logLevel info"
test:markdown:
desc: Lint markdown files
deps:
- deps:ensure-npm
cmds:
- "{{.NPM_CMD}} run test:markdown"
test:html:
desc: Validate HTML
deps:
- deps:ensure-npm
cmds:
- "{{.NPM_CMD}} run test:html"
@ -67,6 +79,18 @@ tasks:
- htmltest
# Development tasks
deps:ensure-npm:
desc: Ensure npm dependencies are installed
sources:
- package.json
- package-lock.json
generates:
- node_modules/.package-lock.json
cmds:
- "{{.NPM_CMD}} install"
status:
- test -d node_modules
deps:install:
desc: Install all dependencies
cmds: