diff --git a/.electron-vue/build.js b/.electron-vue/build.js index dd60a3b..722d648 100644 --- a/.electron-vue/build.js +++ b/.electron-vue/build.js @@ -24,93 +24,95 @@ else if (process.env.BUILD_TARGET === 'web') web() else build() function clean () { - del.sync(['build/*', '!build/icons', '!build/icons/icon.*']) - console.log(`\n${doneLog}\n`) - process.exit() + del.sync(['build/*', '!build/icons', '!build/icons/icon.*']) + console.log(`\n${doneLog}\n`) + process.exit() } function build () { - greeting() + greeting() - del.sync(['dist/electron/*', '!.gitkeep']) + del.sync(['dist/electron/*', '!.gitkeep']) - const tasks = ['main', 'renderer'] - const m = new Multispinner(tasks, { - preText: 'building', - postText: 'process' - }) + const tasks = ['main', 'renderer'] + const m = new Multispinner(tasks, { + preText: 'building', + postText: 'process' + }) - let results = '' + let results = '' - m.on('success', () => { - process.stdout.write('\x1B[2J\x1B[0f') - console.log(`\n\n${results}`) - console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`) - process.exit() - }) - - pack(mainConfig).then(result => { - results += result + '\n\n' - m.success('main') - }).catch(err => { - m.error('main') - console.log(`\n ${errorLog}failed to build main process`) - console.error(`\n${err}\n`) - process.exit(1) - }) - - pack(rendererConfig).then(result => { - results += result + '\n\n' - m.success('renderer') - }).catch(err => { - m.error('renderer') - console.log(`\n ${errorLog}failed to build renderer process`) - console.error(`\n${err}\n`) - process.exit(1) - }) + m.on('success', () => { + process.stdout.write('\x1B[2J\x1B[0f') + console.log(`\n\n${results}`) + console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`) + process.exit() + }) + + pack(mainConfig).then(result => { + results += result + '\n\n' + m.success('main') + }).catch(err => { + m.error('main') + console.log(`\n ${errorLog}failed to build main process`) + console.error(`\n${err}\n`) + process.exit(1) + }) + + pack(rendererConfig).then(result => { + results += result + '\n\n' + m.success('renderer') + }).catch(err => { + m.error('renderer') + console.log(`\n ${errorLog}failed to build renderer process`) + console.error(`\n${err}\n`) + process.exit(1) + }) } function pack (config) { - return new Promise((resolve, reject) => { - webpack(config, (err, stats) => { - if (err) reject(err.stack || err) - else if (stats.hasErrors()) { - let err = '' - - stats.toString({ - chunks: false, - colors: true + return new Promise((resolve, reject) => { + config.mode = 'production' + webpack(config, (err, stats) => { + if (err) reject(err.stack || err) + else if (stats.hasErrors()) { + let err = '' + + stats.toString({ + chunks: false, + colors: true + }) + .split(/\r?\n/) + .forEach(line => { + err += ` ${line}\n` + }) + + reject(err) + } else { + resolve(stats.toString({ + chunks: false, + colors: true + })) + } }) - .split(/\r?\n/) - .forEach(line => { - err += ` ${line}\n` - }) - - reject(err) - } else { - resolve(stats.toString({ - chunks: false, - colors: true - })) - } }) - }) } function web () { - del.sync(['dist/web/*', '!.gitkeep']) - webpack(webConfig, (err, stats) => { - if (err || stats.hasErrors()) console.log(err) - - console.log(stats.toString({ - chunks: false, - colors: true - })) + del.sync(['dist/web/*', '!.gitkeep']) + webConfig.mode = 'production' + webpack(webConfig, (err, stats) => { + if (err || stats.hasErrors()) console.log(err) + + console.log(stats.toString({ + chunks: false, + colors: true + })) - process.exit() - }) + process.exit() + }) } function greeting () { console.log('WOW such build\n'); -} +} \ No newline at end of file diff --git a/.electron-vue/dev-client.js b/.electron-vue/dev-client.js index 2913ea4..f9ba085 100644 --- a/.electron-vue/dev-client.js +++ b/.electron-vue/dev-client.js @@ -1,23 +1,23 @@ const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') hotClient.subscribe(event => { - /** - * Reload browser when HTMLWebpackPlugin emits a new index.html - * - * Currently disabled until jantimon/html-webpack-plugin#680 is resolved. - * https://github.com/SimulatedGREG/electron-vue/issues/437 - * https://github.com/jantimon/html-webpack-plugin/issues/680 - */ - // if (event.action === 'reload') { - // window.location.reload() - // } + /** + * Reload browser when HTMLWebpackPlugin emits a new index.html + * + * Currently disabled until jantimon/html-webpack-plugin#680 is resolved. + * https://github.com/SimulatedGREG/electron-vue/issues/437 + * https://github.com/jantimon/html-webpack-plugin/issues/680 + */ + // if (event.action === 'reload') { + // window.location.reload() + // } - /** - * Notify `mainWindow` when `main` process is compiling, - * giving notice for an expected reload of the `electron` process - */ - if (event.action === 'compiling') { - document.body.innerHTML += ` + /** + * Notify `mainWindow` when `main` process is compiling, + * giving notice for an expected reload of the `electron` process + */ + if (event.action === 'compiling') { + document.body.innerHTML += `