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",
|
"$schema": "https://raw.githubusercontent.com/electron-userland/electron-builder/master/packages/app-builder-lib/scheme.json",
|
||||||
"appId": "YourAppID",
|
"appId": "YourAppID",
|
||||||
"asar": true,
|
"asar": true,
|
||||||
|
"productName": "YourAppName",
|
||||||
"directories": {
|
"directories": {
|
||||||
"output": "release/${version}"
|
"output": "release/${version}"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist-electron",
|
"dist",
|
||||||
"dist"
|
"dist-electron"
|
||||||
],
|
],
|
||||||
"mac": {
|
"mac": {
|
||||||
"artifactName": "${productName}_${version}.${ext}",
|
|
||||||
"target": [
|
"target": [
|
||||||
"dmg"
|
"dmg"
|
||||||
]
|
],
|
||||||
|
"artifactName": "${productName}-Mac-${version}-Installer.${ext}"
|
||||||
},
|
},
|
||||||
"win": {
|
"win": {
|
||||||
"target": [
|
"target": [
|
||||||
@ -27,12 +28,18 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"artifactName": "${productName}_${version}.${ext}"
|
"artifactName": "${productName}-Windows-${version}-Setup.${ext}"
|
||||||
},
|
},
|
||||||
"nsis": {
|
"nsis": {
|
||||||
"oneClick": false,
|
"oneClick": false,
|
||||||
"perMachine": false,
|
"perMachine": false,
|
||||||
"allowToChangeInstallationDirectory": true,
|
"allowToChangeInstallationDirectory": true,
|
||||||
"deleteAppDataOnUninstall": false
|
"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 vue from '@vitejs/plugin-vue'
|
||||||
import electron from 'vite-plugin-electron'
|
import electron from 'vite-plugin-electron'
|
||||||
import renderer from 'vite-plugin-electron-renderer'
|
import renderer from 'vite-plugin-electron-renderer'
|
||||||
|
import { notBundle } from 'vite-plugin-electron/plugin'
|
||||||
import pkg from './package.json'
|
import pkg from './package.json'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
@ -18,13 +19,13 @@ export default defineConfig(({ command }) => {
|
|||||||
vue(),
|
vue(),
|
||||||
electron([
|
electron([
|
||||||
{
|
{
|
||||||
// Main-Process entry file of the Electron App.
|
// Main process entry file of the Electron App.
|
||||||
entry: 'electron/main/index.ts',
|
entry: 'electron/main/index.ts',
|
||||||
onstart(options) {
|
onstart({ startup }) {
|
||||||
if (process.env.VSCODE_DEBUG) {
|
if (process.env.VSCODE_DEBUG) {
|
||||||
console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App')
|
console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App')
|
||||||
} else {
|
} else {
|
||||||
options.startup()
|
startup()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
vite: {
|
vite: {
|
||||||
@ -33,17 +34,26 @@ export default defineConfig(({ command }) => {
|
|||||||
minify: isBuild,
|
minify: isBuild,
|
||||||
outDir: 'dist-electron/main',
|
outDir: 'dist-electron/main',
|
||||||
rollupOptions: {
|
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 : {}),
|
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',
|
entry: 'electron/preload/index.ts',
|
||||||
onstart(options) {
|
onstart({ reload }) {
|
||||||
// Notify the Renderer-Process to reload the page when the Preload-Scripts build is complete,
|
// Notify the Renderer process to reload the page when the Preload scripts build is complete,
|
||||||
// instead of restarting the entire Electron App.
|
// instead of restarting the entire Electron App.
|
||||||
options.reload()
|
reload()
|
||||||
},
|
},
|
||||||
vite: {
|
vite: {
|
||||||
build: {
|
build: {
|
||||||
@ -54,10 +64,13 @@ export default defineConfig(({ command }) => {
|
|||||||
external: Object.keys('dependencies' in pkg ? pkg.dependencies : {}),
|
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(),
|
renderer(),
|
||||||
],
|
],
|
||||||
server: process.env.VSCODE_DEBUG && (() => {
|
server: process.env.VSCODE_DEBUG && (() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user