Skip to content

Migration from v4

General Changes

Deprecation of externalizeDepsPlugin

The externalizeDepsPlugin is deprecated. In v5, you can use build.externalizeDeps to customize this behavior. This feature is enabled by default, so you no longer need to import the plugin.

electron.vite.config.ts
js
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import { defineConfig } from 'electron-vite'

export default defineConfig({
  main: {
    plugins: [externalizeDepsPlugin()] 
  },
  preload: {
    plugins: [externalizeDepsPlugin()] 
  }
  // ...
})

Deprecation of bytecodePlugin

The bytecodePlugin is deprecated. In v5, you can use build.bytecode to enable or customize this feature.

electron.vite.config.ts
js
import { defineConfig, bytecodePlugin } from 'electron-vite'
import { defineConfig } from 'electron-vite'

export default defineConfig({
  main: {
    plugins: [bytecodePlugin()] 
    build: { 
      bytecode: true
    } 
  },
  preload: {
    plugins: [bytecodePlugin()] 
    build: { 
      bytecode: true
    } 
  },
  // ...
})
electron.vite.config.ts
js
import { defineConfig, bytecodePlugin } from 'electron-vite'
import { defineConfig } from 'electron-vite'

export default defineConfig({
  main: {
    plugins: [bytecodePlugin({ protectedStrings: ['foo'] })] 
    build: { 
      bytecode: { protectedStrings: ['foo'] } 
    } 
  },
  // ...
})

Configuration Changes

remove function resolution for nested config fields

In v5, function-based configuration is no longer supported for nested config fields such as main, preload, or renderer. Instead, you should directly define static configuration objects.

js
import { defineConfig, defineViteConfig } from 'electron-vite'

export default defineConfig({
  main: {
    // ...
  },
  preload: {
    // ...
  },
  renderer: defineViteConfig(({ command, mode }) => { ❌ 
    // ...
  })
})

Released under the MIT License