
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
vite-plugin-electron
Advanced tools
Integrate Vite and Electron
Example 👉 vite-plugin-electron-quick-start
vite.config.ts
import electron from 'vite-plugin-electron'
import electronConfig from './vite-electron.config'
export {
plugins: [
electron(electronConfig),
],
}
vite-electron.config.ts
import { defineConfig } from 'vite-plugin-electron'
export default defineConfig({
main: {
entry: 'electron-main.ts',
},
})
electron(config: Configuration)
import type { LibraryOptions, UserConfig } from 'vite'
import type { InputOption } from 'rollup'
export interface Configuration {
main: {
/**
* Shortcut of `build.lib.entry`
*/
entry: LibraryOptions['entry']
vite?: UserConfig
}
preload?: {
/**
* Shortcut of `build.rollupOptions.input`
*/
input: InputOption
vite?: UserConfig
}
}
This plugin is just a builtin scripts of electron-vite-boilerplate
Use Electron and Node.js API in Renderer-process
If you only need to build the Renderer-process, you can just use the
vite-plugin-electron/renderer
plugin
Example 👉 electron-vite-boilerplate
// renderer/vite.config.ts
import electronRenderer from 'vite-plugin-electron/renderer'
export default {
plugins: [
electronRenderer(),
],
}
vite.config.ts
import electronRenderer from 'vite-plugin-electron/renderer'
export default {
plugins: [
electronRenderer(),
],
}
renderer.js
import { readFile } from 'fs'
import { ipcRenderer } from 'electron'
readFile(/* something code... */)
ipcRenderer.on('event-name', () => {/* something code... */})
Using Electron API in Renderer-process
import { ipcRenderer } from 'electron'
Actually redirect to node_modules/vite-plugin-electron/renderer/modules/electron-renderer.js by resolve.alias
Using Node.js API in Renderer-process
import { readFile } from 'fs'
All Node.js API will be built into the node_modules/.vite-plugin-electron-renderer
directory by vite-plugin-optimizer
Config presets
If you do not configure the following options, the plugin will modify their default values
base = './'
build.assetsDir = ''
-> TODO: Automatic splicing build.assetsDir
build.rollupOptions.output.format = 'cjs'
resolve.conditions = ['node']
The plugin transform Electron and Node.js built-in modules to ESModule format in vite serve
phase.
Add Electron and Node.js built-in modules to Rollup output.external
option in the vite build
phase.
FAQs
Electron 🔗 Vite
The npm package vite-plugin-electron receives a total of 25,614 weekly downloads. As such, vite-plugin-electron popularity was classified as popular.
We found that vite-plugin-electron demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.