npm install electron --save dev
## or
yarn add electron --dev
// app.js
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
// app.js
let url
if(process.env.NODE_ENV === 'DEV') {
url = 'http://localhost:8080'
} else {
url = `file:/${process.cwd()}/dist/index.html`
}
// app.js
app.on('ready', () => {
const window = new BrowserWindow({ width: 800, height: 600 })
window.loadURL(url)
})
// package.json
"scripts": {
"electron:serve": "NODE_ENV=DEV vue-cli-service serve &&
sleep 5 && NODE_ENV=DEV electron app.js",
"electron:build": "electron app.js"
}
// vue.config.js
module.exports = {
publicPath: process.env.NODE_ENV === "production"
? `${process.cwd()}/dist/`
: '/'
}
Image by Tsuki Butterflah
Image by Tsuki Butterflah