Vite plugin that converts Makefile targets into vite-plus tasks
[!CAUTION]
Vite+ is currently in alpha and its plugin APIs (especially therun.tasksconfig hook) are subject to breaking changes. Do not use this plugin in production yet. This plugin will be ready for use once Vite+ reaches a stable release.
[!WARNING]
This plugin does not work yet. Therun.tasksconfiguration via the pluginconfighook relies on voidzero-dev/vite-plus#1213, which has been reverted. The underlyingvite.configAPI is still under discussion in vitejs/vite#22085. This plugin will be functional once the upstream API is finalized and re-landed.
Vite plugin that converts Makefile targets into vite-plus tasks
.PHONY targets from MakefilesdependsOn task dependenciesvp add -D vite-plugin-makefile
// vite.config.ts
import { defineConfig, lazyPlugins } from 'vite-plus'
import { Makefile } from 'vite-plugin-makefile'
export default defineConfig({
plugins: [
lazyPlugins(() => {
return [
Makefile({
include: ['.', 'infra'],
exclude: [],
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.ts
The 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"] }
}
includestring[]['.']List of directories to scan for Makefiles (relative to workspace root).
excludestring[][]Target names to exclude from task generation.
prefix'directory' | 'none' | ((dir: string, target: string) => string)'directory'Task name prefix strategy.
'directory': Use directory name as prefix (e.g. infra/docker-up)'none': No prefix (throws on name conflicts)(dir, target) => taskName for custom namingcachebooleantrueEnable caching for all generated tasks.
.PHONY targets are converted to tasks$(VAR)) is not supported%.o: %.c) are not supported$(MAKE) -C subdir) is not supported — use the include option insteadifeq / ifdef) are not supportedThis plugin is powered by:
makefile-lossless, created by Jelmer VernooijNAPI-RS, created by LongYinan and NAPI-RS communityThank you! ❤️