Registry / devops / vite-plugin-target

vite-plugin-target

JSON →
library0.1.1jsnpmunverified

A Vite plugin that makes Vite support Electron (main, preload, renderer) and Node.js targets. Current stable version is 0.1.1 with no frequent releases; it provides a minimal, configuration-based approach to adapt Vite's build for non-browser environments. Its key differentiator is unified API for multiple targets, though alternative tools like electron-vite or vite-plugin-electron offer more comprehensive Electron support. The plugin is early-stage and may have limited community adoption.

npm install vite-plugin-target
INSTALL
IMPORT
SIG · VITE-PLUGIN-TARGET
V
vite-plugin-target
devopsjavascriptv0.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import target from 'vite-plugin-target'
const target = require('vite-plugin-target')
ESM-only package; cannot be used with CommonJS require().
target
import target from 'vite-plugin-target'
import { target } from 'vite-plugin-target'
Default export, not a named export.
Options
import type { Options } from 'vite-plugin-target'
TypeScript type import for type-checking options.

Demonstrates basic usage of vite-plugin-target for Electron renderer with nodeIntegration enabled in Vite config.

import { defineConfig } from 'vite'; import target from 'vite-plugin-target'; export default defineConfig({ plugins: [ target({ 'electron-renderer': { nodeIntegration: true, }, }), ], });
Debug
Known issues
gotchaThe plugin is in early development (v0.1.1); API may change without major version bump.
fix
Pin to exact version and check changelog before upgrading.
affects: >=0.0.0
gotchaFor Electron renderer with nodeIntegration disabled, importing electron may fail unless handled differently.
fix
Set nodeIntegration: true or use alternative approach (e.g., preload with contextBridge).
affects: >=0.0.0
gotchaThe plugin only works with Vite's ESM build; CJS output is not supported for target environments.
fix
Ensure Vite's build target and format are set appropriately (e.g., esm).
affects: >=0.0.0
Errors
Common errors & fixes
The plugin 'vite-plugin-target' requires Vite >=3.0.0
Outdated Vite version (e.g., v2.x).
fix
Update Vite to v3 or later: npm install vite@latest
Uncaught ReferenceError: require is not defined (in electron renderer)
Using nodeIntegration disabled but trying to require('electron').
fix
Enable nodeIntegration in the target options or use preload script with contextBridge.
Cannot find module 'vite-plugin-target' or its corresponding type declarations.
Missing installation or incorrect import path.
fix
Install the package: npm install -D vite-plugin-target
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
viterequiredrequired peer dependency; the plugin is a Vite plugin
Agent activity
4 hits · last 30 days
node
4
Resources
vite-plugin-target — npm install vite-plugin-target · libregistry