Skip to content

Commit

Permalink
improve build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mubaidr committed May 29, 2018
1 parent 65d1d05 commit b42fc8c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 23 deletions.
28 changes: 19 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,27 @@
}
]
},
"files": ["dist/electron/**/*"],
"files": [
"dist/electron/**/*"
],
"linux": {
"icon": "build/icons"
"icon": "build/icons",
"publish": [
"github"
]
},
"mac": {
"icon": "build/icons/icon.icns"
"icon": "build/icons/icon.icns",
"publish": [
"github"
]
},
"productName": "productName",
"win": {
"icon": "build/icons/icon.ico"
"icon": "build/icons/icon.ico",
"publish": [
"github"
]
}
},
"dependencies": {
Expand Down Expand Up @@ -108,12 +119,11 @@
"lint": "eslint --ext .js,.vue src test",
"lint:fix": "eslint --ext .js,.vue --fix src test",
"pack": "cross-env NODE_ENV=production npm run pack:main && npm run pack:renderer",
"pack:main":
"webpack --mode production --progress --config vue-electron/webpack.main.config.js",
"pack:renderer":
"webpack --mode production --progress --config vue-electron/webpack.renderer.config.js",
"pack:main": "webpack --mode production --hide-modules --config vue-electron/webpack.main.config.js",
"pack:renderer": "webpack --mode production --hide-modules --config vue-electron/webpack.renderer.config.js",
"postinstall": "electron-builder install-app-deps && npm rebuild node-sass",
"rebuild-electron": "./node_modules/.bin/electron-rebuild"
"rebuild-electron": "./node_modules/.bin/electron-rebuild",
"release": "build"
},
"version": "0.0.1"
}
32 changes: 20 additions & 12 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true
let mainWindow
let winURL = 'http://localhost:9080'

if (process.env.NODE_ENV === 'production') {
if (process.env.NODE_ENV === 'development') {
try {
// eslint-disable-next-line
require('electron-debug')({
showDevTools: true
})
} catch (err) {
console.log('Failed to install `electron-debug`: Please set `NODE_ENV=production` before build to avoid installing debugging packages. ')
}
} else {
winURL = `file://${__dirname}/index.html`

/**
Expand All @@ -18,17 +27,14 @@ if (process.env.NODE_ENV === 'production') {
global.__static = require('path')
.join(__dirname, '/static')
.replace(/\\/g, '\\\\') // eslint-disable-line
} else {
// eslint-disable-next-line
require('electron-debug')({
showDevTools: true
})
}

function installDevTools() {
if (process.env.NODE_ENV === 'development') {
try {
require('devtron').install() //eslint-disable-line
require('vue-devtools').install() //eslint-disable-line
} catch (err) {
console.log('Failed to install `devtron` & `vue-devtools`: Please set `NODE_ENV=production` before build to avoid installing debugging packages. ')
}
}

Expand All @@ -46,19 +52,18 @@ function createWindow() {
webPreferences: {
nodeIntegrationInWorker: true,
webSecurity: false
}
// show: false,
},
show: false
})

// mainWindow.setMenu(null)
mainWindow.loadURL(winURL)

/* Show when loaded
// Show when loaded
mainWindow.on('ready-to-show', () => {
mainWindow.show()
mainWindow.focus()
})
*/

mainWindow.on('closed', () => {
mainWindow = null
Expand All @@ -67,7 +72,10 @@ function createWindow() {

app.on('ready', () => {
createWindow()
installDevTools()

if (process.env.NODE_ENV === 'development') {
installDevTools()
}
})

app.on('window-all-closed', () => {
Expand Down
4 changes: 2 additions & 2 deletions vue-electron/dev-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ function startMain() {
}

function init() {
console.log('Starting pack scripts...')
console.log('\nStarting pack scripts...')

Promise.all([startRenderer(), startMain()])
.then(() => {
console.log('Starting electron...')
console.log('\nStarting electron...')
startElectron()
})
.catch((err) => {
Expand Down

0 comments on commit b42fc8c

Please sign in to comment.