mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-31 12:06:40 +08:00
feat: better config
This commit is contained in:
parent
c306cd51e2
commit
e1425fb8e8
@ -5,18 +5,19 @@
|
||||
"$schema": "https://raw.githubusercontent.com/electron-userland/electron-builder/master/packages/app-builder-lib/scheme.json",
|
||||
"appId": "YourAppID",
|
||||
"asar": true,
|
||||
"productName": "YourAppName",
|
||||
"directories": {
|
||||
"output": "release/${version}"
|
||||
},
|
||||
"files": [
|
||||
"dist-electron",
|
||||
"dist"
|
||||
"dist",
|
||||
"dist-electron"
|
||||
],
|
||||
"mac": {
|
||||
"artifactName": "${productName}_${version}.${ext}",
|
||||
"target": [
|
||||
"dmg"
|
||||
]
|
||||
],
|
||||
"artifactName": "${productName}-Mac-${version}-Installer.${ext}"
|
||||
},
|
||||
"win": {
|
||||
"target": [
|
||||
@ -27,12 +28,18 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"artifactName": "${productName}_${version}.${ext}"
|
||||
"artifactName": "${productName}-Windows-${version}-Setup.${ext}"
|
||||
},
|
||||
"nsis": {
|
||||
"oneClick": false,
|
||||
"perMachine": false,
|
||||
"allowToChangeInstallationDirectory": true,
|
||||
"deleteAppDataOnUninstall": false
|
||||
},
|
||||
"linux": {
|
||||
"target": [
|
||||
"AppImage"
|
||||
],
|
||||
"artifactName": "${productName}-Linux-${version}.${ext}"
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import electron from 'vite-plugin-electron'
|
||||
import renderer from 'vite-plugin-electron-renderer'
|
||||
import { notBundle } from 'vite-plugin-electron/plugin'
|
||||
import pkg from './package.json'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
@ -18,13 +19,13 @@ export default defineConfig(({ command }) => {
|
||||
vue(),
|
||||
electron([
|
||||
{
|
||||
// Main-Process entry file of the Electron App.
|
||||
// Main process entry file of the Electron App.
|
||||
entry: 'electron/main/index.ts',
|
||||
onstart(options) {
|
||||
onstart({ startup }) {
|
||||
if (process.env.VSCODE_DEBUG) {
|
||||
console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App')
|
||||
} else {
|
||||
options.startup()
|
||||
startup()
|
||||
}
|
||||
},
|
||||
vite: {
|
||||
@ -33,17 +34,26 @@ export default defineConfig(({ command }) => {
|
||||
minify: isBuild,
|
||||
outDir: 'dist-electron/main',
|
||||
rollupOptions: {
|
||||
// Some third-party Node.js libraries may not be built correctly by Vite, especially `C/C++` addons,
|
||||
// we can use `external` to exclude them to ensure they work correctly.
|
||||
// Others need to put them in `dependencies` to ensure they are collected into `app.asar` after the app is built.
|
||||
// Of course, this is not absolute, just this way is relatively simple. :)
|
||||
external: Object.keys('dependencies' in pkg ? pkg.dependencies : {}),
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
// This is just an option to improve build performance, it's non-deterministic!
|
||||
// e.g. `import log from 'electron-log'` -> `const log = require('electron-log')`
|
||||
isServe && notBundle(),
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
entry: 'electron/preload/index.ts',
|
||||
onstart(options) {
|
||||
// Notify the Renderer-Process to reload the page when the Preload-Scripts build is complete,
|
||||
onstart({ reload }) {
|
||||
// Notify the Renderer process to reload the page when the Preload scripts build is complete,
|
||||
// instead of restarting the entire Electron App.
|
||||
options.reload()
|
||||
reload()
|
||||
},
|
||||
vite: {
|
||||
build: {
|
||||
@ -54,10 +64,13 @@ export default defineConfig(({ command }) => {
|
||||
external: Object.keys('dependencies' in pkg ? pkg.dependencies : {}),
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
isServe && notBundle(),
|
||||
],
|
||||
},
|
||||
}
|
||||
]),
|
||||
// Use Node.js API in the Renderer-process
|
||||
// Use Node.js API in the Renderer process
|
||||
renderer(),
|
||||
],
|
||||
server: process.env.VSCODE_DEBUG && (() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user