{"id":22878,"library":"vite-plugin-target","title":"vite-plugin-target","description":"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.","status":"active","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/vite-plugin/vite-plugin-target","tags":["javascript","vite","plugin","target","electron","typescript"],"install":[{"cmd":"npm install vite-plugin-target","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-target","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-target","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"required peer dependency; the plugin is a Vite plugin","package":"vite","optional":false}],"imports":[{"note":"ESM-only package; cannot be used with CommonJS require().","wrong":"const target = require('vite-plugin-target')","symbol":"default","correct":"import target from 'vite-plugin-target'"},{"note":"Default export, not a named export.","wrong":"import { target } from 'vite-plugin-target'","symbol":"target","correct":"import target from 'vite-plugin-target'"},{"note":"TypeScript type import for type-checking options.","wrong":null,"symbol":"Options","correct":"import type { Options } from 'vite-plugin-target'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport target from 'vite-plugin-target';\n\nexport default defineConfig({\n  plugins: [\n    target({\n      'electron-renderer': {\n        nodeIntegration: true,\n      },\n    }),\n  ],\n});\n","lang":"typescript","description":"Demonstrates basic usage of vite-plugin-target for Electron renderer with nodeIntegration enabled in Vite config."},"warnings":[{"fix":"Pin to exact version and check changelog before upgrading.","message":"The plugin is in early development (v0.1.1); API may change without major version bump.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set nodeIntegration: true or use alternative approach (e.g., preload with contextBridge).","message":"For Electron renderer with nodeIntegration disabled, importing electron may fail unless handled differently.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure Vite's build target and format are set appropriately (e.g., esm).","message":"The plugin only works with Vite's ESM build; CJS output is not supported for target environments.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Update Vite to v3 or later: npm install vite@latest","cause":"Outdated Vite version (e.g., v2.x).","error":"The plugin 'vite-plugin-target' requires Vite >=3.0.0"},{"fix":"Enable nodeIntegration in the target options or use preload script with contextBridge.","cause":"Using nodeIntegration disabled but trying to require('electron').","error":"Uncaught ReferenceError: require is not defined (in electron renderer)"},{"fix":"Install the package: npm install -D vite-plugin-target","cause":"Missing installation or incorrect import path.","error":"Cannot find module 'vite-plugin-target' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}