
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
Electron ๐ Vite
English | ็ฎไฝไธญๆ
npm i vite-plugin-electron -D
vite.config.ts
import electron from 'vite-plugin-electron'
export default {
plugins: [
electron({
entry: 'electron/main.ts',
}),
],
}
You can use process.env.VITE_DEV_SERVER_URL
when the vite command is called 'serve'
// electron main.js
const win = new BrowserWindow({
title: 'Main window',
})
if (process.env.VITE_DEV_SERVER_URL) {
win.loadURL(process.env.VITE_DEV_SERVER_URL)
} else {
// load your file
win.loadFile('yourOutputFile.html');
}
electron(config: Configuration | Configuration[])
export interface Configuration {
/**
* Shortcut of `build.lib.entry`
*/
entry?: import('vite').LibraryOptions['entry']
vite?: import('vite').InlineConfig
/**
* Triggered when Vite is built every time -- `vite serve` command only.
*
* If this `onstart` is passed, Electron App will not start automatically.
* However, you can start Electroo App via `startup` function.
*/
onstart?: (this: import('rollup').PluginContext, options: {
/**
* Electron App startup function.
* It will mount the Electron App child-process to `process.electronApp`.
* @param argv default value `['.', '--no-sandbox']`
*/
startup: (argv?: string[]) => Promise<void>
/** Reload Electron-Renderer */
reload: () => void
}) => void | Promise<void>
}
vite-plugin-electron
's JavaScript APIs are fully typed, and it's recommended to use TypeScript or enable JS type checking in VS Code to leverage the intellisense and validation.
Configuration
- typedefineConfig
- functionresolveViteConfig
- function, Resolve the default Vite's InlineConfig
for build Electron-MainwithExternalBuiltins
- functionbuild
- functionstartup
- functionExample
build(
withExternalBuiltins( // external Node.js builtin modules
resolveViteConfig( // with default config
{
entry: 'foo.ts',
vite: {
mode: 'foo-mode', // for .env file
plugins: [{
name: 'plugin-build-done',
closeBundle() {
// Startup Electron App
startup()
},
}],
},
}
)
)
)
It just executes the electron .
command in the Vite build completion hook and then starts or restarts the Electron App.
Let's use the official template-vanilla-ts created based on create vite
as an example
+ โโโฌ electron
+ โ โโโ main.ts
โโโฌ src
โ โโโ main.ts
โ โโโ style.css
โ โโโ vite-env.d.ts
โโโ .gitignore
โโโ favicon.svg
โโโ index.html
โโโ package.json
โโโ tsconfig.json
+ โโโ vite.config.ts
electron
folder will be built into the dist-electron
"type": "module"
is not supported in Electrondependencies
. Unless you know how to properly build them with Vite.
electron({
entry: 'electron/main.ts',
vite: {
build: {
rollupOptions: {
// Here are some C/C++ plugins that can't be built properly.
external: [
'serialport',
'sqlite3',
],
},
},
},
}),
FAQs
Electron ๐ Vite
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.