feat(build): add automatic npm dependency management
All checks were successful
ci / build (push) Successful in 52s

- 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 tasks
build: build:
desc: Build Hugo site desc: Build Hugo site
deps:
- deps:ensure-npm
cmds: cmds:
- "{{.HUGO_CMD}} --gc --minify" - "{{.HUGO_CMD}} --gc --minify"
build:dev: build:dev:
desc: Build Hugo site for development desc: Build Hugo site for development
deps:
- deps:ensure-npm
cmds: cmds:
- "{{.HUGO_CMD}}" - "{{.HUGO_CMD}}"
serve: serve:
desc: Start Hugo dev server desc: Start Hugo dev server
deps:
- deps:ensure-npm
cmds: cmds:
- "{{.HUGO_CMD}} server" - "{{.HUGO_CMD}} server"
@ -48,16 +54,22 @@ tasks:
test:build: test:build:
desc: Test Hugo build desc: Test Hugo build
deps:
- deps:ensure-npm
cmds: cmds:
- "{{.HUGO_CMD}} --gc --minify --logLevel info" - "{{.HUGO_CMD}} --gc --minify --logLevel info"
test:markdown: test:markdown:
desc: Lint markdown files desc: Lint markdown files
deps:
- deps:ensure-npm
cmds: cmds:
- "{{.NPM_CMD}} run test:markdown" - "{{.NPM_CMD}} run test:markdown"
test:html: test:html:
desc: Validate HTML desc: Validate HTML
deps:
- deps:ensure-npm
cmds: cmds:
- "{{.NPM_CMD}} run test:html" - "{{.NPM_CMD}} run test:html"
@ -67,6 +79,18 @@ tasks:
- htmltest - htmltest
# Development tasks # 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: deps:install:
desc: Install all dependencies desc: Install all dependencies
cmds: cmds: