Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

vite-plugin-electron

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-electron - npm Package Versions

1
…
…
8

0.11.0

Diff

Changelog

Source

0.11.0 (2022-12-17)

Break!
// 0.10.0
function build(config: Configuration | Configuration[]): Promise<void>

// 0.11.0 - Same as Vite's build
function build(config: Configuration): Promise<RollupOutput | RollupOutput[] | RollupWatcher>
Features

JavaScript API

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 - type
  • defineConfig - function
  • resolveViteConfig - function, Resolve the default Vite's InlineConfig for build Electron-Main
  • withExternalBuiltins - function
  • build - function
  • startup - function

Example:

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()
            },
          }],
        },
      }
    )
  )
)

V8 Bytecode support πŸ‘‰ bytecode

Inspired by:

Commit/PR
  • Support Vite4.x | #118, 28d38b6
  • Bytecode example | df170c2
  • JavaScript API docs | 3049169
  • Fix load .env | 758695d
  • Refactor build() | d9c3343
caoxie
published 0.10.4 β€’

Changelog

Source

0.10.4 (2022-11-13)

  • e4f943f refactor: move build.resolve to resolve
  • 91fb525 docs(zh-CN): update | @ggdream
  • 41db615 Use mode from source config. | #105, #106
caoxie
published 0.10.3 β€’

Changelog

Source

0.10.3 (2022-11-10)

  • 0b24909 refactor: cleanup, provides some programmable APIs 🌱
  • 58517d8 refactor(proj-struct): remove vite-plugin-electron-renderer
  • d2b3c29 Merge pull request #98 from skyrpex/patch-1
  • 1645be2 fix: ignore the browser field when bundling
caoxie
published 0.10.2 β€’

Changelog

Source

0.10.2 (2022-10-24)

By default, the dist folder will be automatically removed by Vite. We build Electron related files into dist-electron to prevent it from being removed by mistake

  1. Remove Vite 3.2.0 | #90
  2. ad9bb3c refactor(electron-renderer)!: remove options.resolve(), use 'lib-esm' for resolve Node.js modules and electron | vite-plugin-electron-renderer
  3. b500039 feat(electron-renderer): support optimizeDeps for Electron-Renderer πŸš€
  4. f28e66b faet(outDir)!: dist/electron -> dist-electron | vite-plugin-electron
caoxie
published 0.10.1 β€’

Changelog

Source

0.10.1 (2022-10-12)

  • 59a24df fix(electron-renderer): use createRequire() instead of import() 🐞
  • 11cd4c3 feat(electron): onstart provides reload()
caoxie
published 0.10.0 β€’

Changelog

Source

0.10.0 (2022-10-09)

Break!

This is a redesigned version of the API<sub><sup>(Only 3 APIs)</sub></sup>. Not compatible with previous versions!

export type Configuration = {
  /**
   * Shortcut of `build.lib.entry`
   */
  entry?: import('vite').LibraryOptions['entry']
  /**
   * Triggered when Vite is built.  
   * If passed this parameter will not automatically start Electron App.  
   * You can start Electron App through the `startup` function passed through the callback function.  
   */
  onstart?: (this: import('rollup').PluginContext, startup: (args?: string[]) => Promise<void>) => void
  vite?: import('vite').InlineConfig
}

In the past few weeks, some issues have been mentioned in many issues that cannot be solved amicably. So I refactored the API to avoid design flaws. But despite this, the new version will only be easier rather than harder.

For example, some common problems in the following issues.

Multiple entry files is not support #86

Thanks to Vite@3.2.0's lib.entry supports multiple entries, which makes the configuration of the new version very simple. So the vite-plugin-electron@0.10.0 requires Vite at least v3.2.0.

e.g.

import electron from 'vite-plugin-electron'

// In plugins option
electron({
  entry: [
    'electron/entry-1.ts',
    'electron/entry-2.ts',
  ],
})

// Or use configuration array
electron([
  {
    entry: [
      'electron/entry-1.ts',
      'electron/entry-2.ts',
    ],
  },
  {
    entry: 'foo/bar.ts',
  },
])
require is not defined #48, #87

vite-plugin-electron-renderer will change output.format to cjs format by default<sub><sup>(This is because currently Electron@21 only supports CommonJs)</sub></sup>, which will cause the built code to use require to import modules, if the user nodeIntegration is not enabled in the Electron-Main process which causes the error require is not defined to be thrown.

vite-plugin-electron-renderer@0.10.0 provides the nodeIntegration option. It is up to the user to decide whether to use Node.js(CommonJs).

e.g.

import renderer from 'vite-plugin-electron-renderer'

// In plugins option
renderer({
  nodeIntegration: true,
})
Use Worker in Electron-Main or Electron-Renderer #77, #81

You can see πŸ‘‰ examples/worker

  • Use Worker in Electron-Main

    e.g. <sub><sup>This looks the same as multiple entry</sub></sup>

    import electron from 'vite-plugin-electron'
    
    // In plugins option
    electron({
      entry: [
        'electron/main.ts',
        'electron/worker.ts',
      ],
    })
    
    // In electron/main.ts
    new Worker(path.join(__dirname, './worker.js'))
    
  • Use Worker in Electron-Renderer

    e.g.

    import renderer, { worker } from 'vite-plugin-electron-renderer'
    
    export default {
      plugins: [
        renderer({
          // If you need use Node.js in Electron-Renderer process
          nodeIntegration: true,
        }),
      ],
      worker: {
        plugins: [
          worker({
            // If you need use Node.js in Worker
            nodeIntegrationInWorker: true,
          }),
        ],
      },
    }
    
TODO
  • [ ] There is no way to differentiate between Preload-Scripts, which will cause the entire Electron App to restart after the preload update, not the Electron-Renderer reload.
PR

https://github.com/electron-vite/vite-plugin-electron/pull/89

caoxie
published 0.9.3 β€’

Changelog

Source

0.9.3 (2022-09-10)

~~vite-plugin-electron~~

vite-plugin-electron-renderer

  • 191afb8 feat: proxy ipcRenderer in Worker | #69
caoxie
published 0.9.2 β€’

Changelog

Source

0.9.2 (2022-08-29)

vite-plugin-electron

  • 715a1cd fix(electron): VITE_DEV_SERVER_HOSTNAME instead VITE_DEV_SERVER_HOST

vite-plugin-electron-renderer

caoxie
published 0.9.1 β€’

Changelog

Source

0.9.1 (2022-08-24)

vite-plugin-electron

  • db61e49 feat(electron): support custom start 🌱 | #57, #58

~~vite-plugin-electron-renderer~~

caoxie
published 0.9.0 β€’

Changelog

Source

0.9.0 (2022-08-12)

πŸŽ‰ v0.9.0 is a stable version based on vite@3.0.6

~~vite-plugin-electron~~

vite-plugin-electron-renderer

  • ebc6a3d chore(electron-renderer): remove renderBuiltUrl() based on vite@3.0.6 (vite@3.0.6-8f2065e)

1
…
…
8
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc