Skip to content

Instantly share code, notes, and snippets.

@mikeal
Created April 24, 2018 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeal/5389ae0144de7404ab7d889588909e8f to your computer and use it in GitHub Desktop.
Save mikeal/5389ae0144de7404ab7d889588909e8f to your computer and use it in GitHub Desktop.
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
let url
if (process.env.NODE_ENV === 'DEV') {
url = 'http://localhost:8080/'
} else {
url = `file://${process.cwd()}/dist/index.html`
}
app.on('ready', () => {
let window = new BrowserWindow({width: 800, height: 600})
window.loadURL(url)
})
npm run build
electron app.js
{ "scripts":
{ "dev": "NODE_ENV=DEV vue-cli-service serve & sleep 5 && NODE_ENV=DEV electron app.js" }
}
npm install -g @vue/cli
vue create my-project
cd my-project
npm install electron
module.exports = {
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.output.publicPath = `${process.cwd()}/dist/`
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment