Skip to content
This repository was archived by the owner on Sep 13, 2023. It is now read-only.

Commit 8b53008

Browse files
jack-chapmanlauthieb
authored andcommitted
Upgrade project to use latest version of electron-vue (#93)
* Update to use newest version of electron-vue * Fix issue with templates not compiling - vue-loader * Revert Vue version * Change travis node version to 8.x.x
1 parent 29d3a74 commit 8b53008

File tree

15 files changed

+6448
-3619
lines changed

15 files changed

+6448
-3619
lines changed

.electron-vue/build.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function build () {
7272

7373
function pack (config) {
7474
return new Promise((resolve, reject) => {
75+
config.mode = 'production'
7576
webpack(config, (err, stats) => {
7677
if (err) reject(err.stack || err)
7778
else if (stats.hasErrors()) {
@@ -99,6 +100,7 @@ function pack (config) {
99100

100101
function web () {
101102
del.sync(['dist/web/*', '!.gitkeep'])
103+
webConfig.mode = 'production'
102104
webpack(webConfig, (err, stats) => {
103105
if (err || stats.hasErrors()) console.log(err)
104106

@@ -127,4 +129,4 @@ function greeting () {
127129
})
128130
} else console.log(chalk.yellow.bold('\n lets-build'))
129131
console.log()
130-
}
132+
}

.electron-vue/dev-runner.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ function logStats (proc, data) {
4141
function startRenderer () {
4242
return new Promise((resolve, reject) => {
4343
rendererConfig.entry.renderer = [path.join(__dirname, 'dev-client')].concat(rendererConfig.entry.renderer)
44-
44+
rendererConfig.mode = 'development'
4545
const compiler = webpack(rendererConfig)
46-
hotMiddleware = webpackHotMiddleware(compiler, {
47-
log: false,
48-
heartbeat: 2500
46+
hotMiddleware = webpackHotMiddleware(compiler, {
47+
log: false,
48+
heartbeat: 2500
4949
})
5050

51-
compiler.plugin('compilation', compilation => {
52-
compilation.plugin('html-webpack-plugin-after-emit', (data, cb) => {
51+
compiler.hooks.compilation.tap('compilation', compilation => {
52+
compilation.hooks.htmlWebpackPluginAfterEmit.tapAsync('html-webpack-plugin-after-emit', (data, cb) => {
5353
hotMiddleware.publish({ action: 'reload' })
5454
cb()
5555
})
5656
})
5757

58-
compiler.plugin('done', stats => {
58+
compiler.hooks.done.tap('done', stats => {
5959
logStats('Renderer', stats)
6060
})
6161

@@ -80,10 +80,10 @@ function startRenderer () {
8080
function startMain () {
8181
return new Promise((resolve, reject) => {
8282
mainConfig.entry.main = [path.join(__dirname, '../src/main/index.dev.js')].concat(mainConfig.entry.main)
83-
83+
mainConfig.mode = 'development'
8484
const compiler = webpack(mainConfig)
8585

86-
compiler.plugin('watch-run', (compilation, done) => {
86+
compiler.hooks.watchRun.tapAsync('watch-run', (compilation, done) => {
8787
logStats('Main', chalk.white.bold('compiling...'))
8888
hotMiddleware.publish({ action: 'compiling' })
8989
done()
@@ -114,8 +114,20 @@ function startMain () {
114114
}
115115

116116
function startElectron () {
117-
electronProcess = spawn(electron, ['--inspect=5858', path.join(__dirname, '../dist/electron/main.js')])
117+
var args = [
118+
'--inspect=5858',
119+
path.join(__dirname, '../dist/electron/main.js')
120+
]
121+
122+
// detect yarn or npm and process commandline args accordingly
123+
if (process.env.npm_execpath.endsWith('yarn.js')) {
124+
args = args.concat(process.argv.slice(3))
125+
} else if (process.env.npm_execpath.endsWith('npm-cli.js')) {
126+
args = args.concat(process.argv.slice(2))
127+
}
118128

129+
electronProcess = spawn(electron, args)
130+
119131
electronProcess.stdout.on('data', data => {
120132
electronLog(data, 'blue')
121133
})

.electron-vue/webpack.renderer.config.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ const webpack = require('webpack')
88

99
const BabiliWebpackPlugin = require('babili-webpack-plugin')
1010
const CopyWebpackPlugin = require('copy-webpack-plugin')
11-
const ExtractTextPlugin = require('extract-text-webpack-plugin')
11+
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
1212
const HtmlWebpackPlugin = require('html-webpack-plugin')
13+
const { VueLoaderPlugin } = require('vue-loader')
1314

1415
/**
1516
* List of node_modules to include in webpack bundle
@@ -21,7 +22,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
2122
let whiteListedModules = ['vue']
2223

2324
let rendererConfig = {
24-
devtool: '#cheap-module-eval-source-map',
25+
devtool: 'inline-source-map',
2526
entry: {
2627
renderer: path.join(__dirname, '../src/renderer/main.js')
2728
},
@@ -41,12 +42,21 @@ let rendererConfig = {
4142
}
4243
}
4344
},
45+
{
46+
test: /\.scss$/,
47+
use: ['vue-style-loader', 'css-loader', 'sass-loader?data=@import "./src/renderer/globals";']
48+
},
49+
{
50+
test: /\.sass$/,
51+
use: ['vue-style-loader', 'css-loader', 'sass-loader?indentedSyntax&data=@import "./src/renderer/globals"']
52+
},
53+
{
54+
test: /\.less$/,
55+
use: ['vue-style-loader', 'css-loader', 'less-loader']
56+
},
4457
{
4558
test: /\.css$/,
46-
use: ExtractTextPlugin.extract({
47-
fallback: 'style-loader',
48-
use: 'css-loader'
49-
})
59+
use: ['vue-style-loader', 'css-loader']
5060
},
5161
{
5262
test: /\.html$/,
@@ -67,10 +77,11 @@ let rendererConfig = {
6777
loader: 'vue-loader',
6878
options: {
6979
extractCSS: process.env.NODE_ENV === 'production',
70-
loaders: {
71-
sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1&data=@import "./src/renderer/globals"',
72-
scss: 'vue-style-loader!css-loader!sass-loader?data=@import "./src/renderer/globals";'
73-
}
80+
loaders: {
81+
sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1&data=@import "./src/renderer/globals"',
82+
scss: 'vue-style-loader!css-loader!sass-loader?data=@import "./src/renderer/globals";',
83+
less: 'vue-style-loader!css-loader!less-loader'
84+
}
7485
}
7586
}
7687
},
@@ -109,7 +120,8 @@ let rendererConfig = {
109120
__filename: process.env.NODE_ENV !== 'production'
110121
},
111122
plugins: [
112-
new ExtractTextPlugin('styles.css'),
123+
new VueLoaderPlugin(),
124+
new MiniCssExtractPlugin({filename: 'styles.css'}),
113125
new HtmlWebpackPlugin({
114126
filename: 'index.html',
115127
template: path.resolve(__dirname, '../src/index.ejs'),

.electron-vue/webpack.web.config.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ const webpack = require('webpack')
77

88
const BabiliWebpackPlugin = require('babili-webpack-plugin')
99
const CopyWebpackPlugin = require('copy-webpack-plugin')
10-
const ExtractTextPlugin = require('extract-text-webpack-plugin')
10+
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
1111
const HtmlWebpackPlugin = require('html-webpack-plugin')
12+
const { VueLoaderPlugin } = require('vue-loader')
1213

1314
let webConfig = {
1415
devtool: '#cheap-module-eval-source-map',
@@ -28,12 +29,21 @@ let webConfig = {
2829
}
2930
}
3031
},
32+
{
33+
test: /\.scss$/,
34+
use: ['vue-style-loader', 'css-loader', 'sass-loader']
35+
},
36+
{
37+
test: /\.sass$/,
38+
use: ['vue-style-loader', 'css-loader', 'sass-loader?indentedSyntax']
39+
},
40+
{
41+
test: /\.less$/,
42+
use: ['vue-style-loader', 'css-loader', 'less-loader']
43+
},
3144
{
3245
test: /\.css$/,
33-
use: ExtractTextPlugin.extract({
34-
fallback: 'style-loader',
35-
use: 'css-loader'
36-
})
46+
use: ['vue-style-loader', 'css-loader']
3747
},
3848
{
3949
test: /\.html$/,
@@ -53,7 +63,8 @@ let webConfig = {
5363
extractCSS: true,
5464
loaders: {
5565
sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1',
56-
scss: 'vue-style-loader!css-loader!sass-loader'
66+
scss: 'vue-style-loader!css-loader!sass-loader',
67+
less: 'vue-style-loader!css-loader!less-loader'
5768
}
5869
}
5970
}
@@ -81,7 +92,8 @@ let webConfig = {
8192
]
8293
},
8394
plugins: [
84-
new ExtractTextPlugin('styles.css'),
95+
new VueLoaderPlugin(),
96+
new MiniCssExtractPlugin({filename: 'styles.css'}),
8597
new HtmlWebpackPlugin({
8698
filename: 'index.html',
8799
template: path.resolve(__dirname, '../src/index.ejs'),

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://simulatedgreg.gitbooks.io/electron-vue/content/en/testing.html#on-the-subject-of-ci-testing
33
osx_image: xcode8.3
44
language: node_js
5-
node_js: 7.10.1
5+
node_js: 8.16.1
66
matrix:
77
include:
88
- os: osx

0 commit comments

Comments
 (0)