Created
April 24, 2018 22:17
-
-
Save mikeal/5389ae0144de7404ab7d889588909e8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm run build | |
electron app.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "scripts": | |
{ "dev": "NODE_ENV=DEV vue-cli-service serve & sleep 5 && NODE_ENV=DEV electron app.js" } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install -g @vue/cli | |
vue create my-project | |
cd my-project | |
npm install electron |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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