vite-plugin-makefile
raw JSON →Vite plugin that converts Makefile .PHONY targets into vite-plus tasks. Version 0.0.5 is the latest stable release. It automatically discovers Makefiles in specified directories, maps prerequisites to task dependencies, and supports prefix strategies for task names. Built on makefile-lossless via NAPI-RS for efficient parsing. Key differentiator: integrates Makefile targets directly into the vite-plus build system, eliminating the need to manually duplicate tasks. Compared to alternatives like just or taskfile, it reuses existing Makefiles without extra configuration. Limitations: only supports .PHONY targets, no variable expansion, pattern rules, or recursive make. Ideal for projects already using Makefiles that want to leverage vite-plus task execution.
Common errors
error Error: Cannot find module 'vite-plugin-makefile' ↓
error TypeError: Makefile is not a function ↓
error Error: Prefix strategy 'none' caused duplicate task name 'build' ↓
Warnings
gotcha Only .PHONY targets are converted to tasks. Non-phony targets (file targets) are ignored silently. ↓
gotcha Variable expansion ($(VAR)), pattern rules (%.o: %.c), and recursive Make invocations are not supported. These are silently skipped or may cause incorrect behavior. ↓
gotcha Conditional targets (ifeq / ifdef) are not supported. The plugin may misparse or ignore them. ↓
gotcha If prefix strategy is 'none' and two different directories produce the same target name, the plugin will throw an error to avoid name conflicts. ↓
gotcha The plugin relies on a NAPI-RS binding for makefile-lossless. This requires a compatible Node.js version and platform. On unsupported platforms, the plugin may fail to load. ↓
Install
npm install vite-plugin-makefile yarn add vite-plugin-makefile pnpm add vite-plugin-makefile Imports
- Makefile wrong
const { Makefile } = require('vite-plugin-makefile')correctimport { Makefile } from 'vite-plugin-makefile'
Quickstart
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: {
lint: { command: 'vp lint' }
}
}
});