vite-plugin-makefile
v0.0.5
Published
Vite plugin that converts Makefile targets into vite-plus tasks
Maintainers
Readme
vite-plugin-makefile
Vite plugin that converts Makefile targets into vite-plus tasks
✨ Features
- ✅️ Automatically discovers
.PHONYtargets from Makefiles - ✅️ Converts prerequisites into
dependsOntask dependencies - ✅️ Supports multiple directories with prefix strategies
- ✅️ Powered by makefile-lossless via NAPI-RS binding
💿 Installation
vp add -D vite-plugin-makefile🚀 Usage
// vite.config.ts
import { defineConfig } from 'vite-plus'
import { Makefile } from 'vite-plugin-makefile'
export default defineConfig({
plugins: [
Makefile({
include: ['.', 'infra'],
exclude: ['help', 'default'],
prefix: 'directory'
})
],
run: {
tasks: {
// Merged with plugin-generated tasks
lint: { command: 'vp lint' }
}
}
})Given the following project structure:
project/
├── Makefile # .PHONY: build test clean setup
├── infra/
│ └── Makefile # .PHONY: docker-up docker-down migrate
└── vite.config.tsThe plugin generates the following tasks:
{
"build": { "command": "make build", "dependsOn": ["setup"] },
"test": { "command": "make test", "dependsOn": ["build"] },
"clean": { "command": "make clean" },
"setup": { "command": "make setup" },
"infra/docker-up": { "command": "make docker-up", "cwd": "infra" },
"infra/docker-down": { "command": "make docker-down", "cwd": "infra" },
"infra/migrate": { "command": "make migrate", "cwd": "infra", "dependsOn": ["infra/docker-up"] }
}⚙️ Options
include
- Type:
string[] - Default:
['.']
List of directories to scan for Makefiles (relative to workspace root).
exclude
- Type:
string[] - Default:
[]
Target names to exclude from task generation.
prefix
- Type:
'directory' | 'none' | ((dir: string, target: string) => string) - Default:
'directory'
Task name prefix strategy.
'directory': Use directory name as prefix (e.g.infra/docker-up)'none': No prefix (throws on name conflicts)- Function:
(dir, target) => taskNamefor custom naming
cache
- Type:
boolean - Default:
true
Enable caching for all generated tasks.
🚧 Limitations
- Only
.PHONYtargets are converted to tasks - Variable expansion (
$(VAR)) is not supported - Pattern rules (
%.o: %.c) are not supported - Implicit rules are not supported
- Recursive Make (
$(MAKE) -C subdir) is not supported — use theincludeoption instead - Conditional targets (
ifeq/ifdef) are not supported
💖 Credit
This plugin is powered by:
makefile-lossless, created by Jelmer VernooijNAPI-RS, created by LongYinan and NAPI-RS community- Vite+, created by Evan You and VoidZero team
Thank you! ❤️
