diff --git a/.electron-vue/dev-runner.js b/.electron-vue/dev-runner.js index 8cd2a47c..230cf526 100644 --- a/.electron-vue/dev-runner.js +++ b/.electron-vue/dev-runner.js @@ -104,36 +104,11 @@ function startMain() { logStats('Main', stats) - if (electronProcess && electronProcess.kill) { - manualRestart = true - process.kill(electronProcess.pid) - electronProcess = null - startElectron() - - setTimeout(() => { - manualRestart = false - }, 5000) - } - resolve() }) }) } -function startElectron() { - electronProcess = spawn(electron, ['--inspect=5858', path.join(__dirname, '../dist/electron/main.js')]) - - electronProcess.stdout.on('data', data => { - electronLog(data, 'blue') - }) - electronProcess.stderr.on('data', data => { - electronLog(data, 'red') - }) - - electronProcess.on('close', () => { - if (!manualRestart) process.exit() - }) -} function startElectron() { var args = ['--inspect=5858', path.join(__dirname, '../dist/electron/main.js')] diff --git a/.electron-vue/webpack.renderer.config.js b/.electron-vue/webpack.renderer.config.js index 5d5ce288..96d66111 100644 --- a/.electron-vue/webpack.renderer.config.js +++ b/.electron-vue/webpack.renderer.config.js @@ -161,6 +161,7 @@ let rendererConfig = { __filename: process.env.NODE_ENV !== 'production' }, devServer: { + hot: true, hotOnly: true }, plugins: [ diff --git a/.electron-vue/webpack.web.config.js b/.electron-vue/webpack.web.config.js deleted file mode 100644 index 9f273f6e..00000000 --- a/.electron-vue/webpack.web.config.js +++ /dev/null @@ -1,144 +0,0 @@ -'use strict' - -process.env.BABEL_ENV = 'web' - -const path = require('path') -const webpack = require('webpack') - -const CopyWebpackPlugin = require('copy-webpack-plugin') -const MiniCssExtractPlugin = require('mini-css-extract-plugin') -const HtmlWebpackPlugin = require('html-webpack-plugin') -const { VueLoaderPlugin } = require('vue-loader') - -let webConfig = { - entry: { - web: path.join(__dirname, '../src/renderer/main.js') - }, - module: { - rules: [ - { - test: /\.vue$/, - use: { - loader: 'vue-loader', - options: { - extractCSS: true, - loaders: { - sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1', - scss: 'vue-style-loader!css-loader!sass-loader', - less: 'vue-style-loader!css-loader!less-loader' - } - } - } - }, - { - test: /\.scss$/, - use: ['vue-style-loader', 'css-loader', 'sass-loader'] - }, - { - test: /\.sass$/, - use: ['vue-style-loader', 'css-loader', 'sass-loader?indentedSyntax'] - }, - { - test: /\.less$/, - use: ['vue-style-loader', 'css-loader', 'less-loader'] - }, - { - test: /\.css$/, - use: ['vue-style-loader', 'css-loader'] - }, - { - test: /\.html$/, - use: 'vue-html-loader' - }, - { - test: /\.js$/, - use: 'babel-loader', - include: [path.resolve(__dirname, '../src/renderer')], - exclude: /node_modules/ - }, - { - test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, - use: { - loader: 'url-loader', - options: { - limit: 10000, - name: 'imgs/[name].[ext]' - } - } - }, - { - test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, - use: { - loader: 'url-loader', - options: { - limit: 10000, - name: 'fonts/[name].[ext]' - } - } - } - ] - }, - plugins: [ - new VueLoaderPlugin(), - new MiniCssExtractPlugin({ filename: 'styles.css' }), - new HtmlWebpackPlugin({ - filename: 'index.html', - template: path.resolve(__dirname, '../src/index.ejs'), - minify: { - collapseWhitespace: true, - removeAttributeQuotes: true, - removeComments: true - }, - nodeModules: false - }), - new webpack.DefinePlugin({ - 'process.env.IS_WEB': 'true' - }), - new webpack.HotModuleReplacementPlugin(), - new webpack.NoEmitOnErrorsPlugin() - ], - output: { - filename: '[name].js', - path: path.join(__dirname, '../dist/web') - }, - resolve: { - alias: { - '@': path.join(__dirname, '../src/renderer'), - vue$: 'vue/dist/vue.esm.js' - }, - extensions: ['.js', '.vue', '.json', '.css'] - }, - target: 'web' -} - -if (process.env.NODE_ENV !== 'production') { - webConfig.devtool = 'eval-cheap-module-source-map' -} - -/** - * Adjust webConfig for production settings - */ -if (process.env.NODE_ENV === 'production') { - webConfig.mode = 'production' - webConfig.plugins.push( - new CopyWebpackPlugin({ - patterns: [ - { - from: path.join(__dirname, '../static'), - to: path.join(__dirname, '../dist/web/static'), - globOptions: { - ignore: ['.*', '*~'] - } - } - ] - }), - new webpack.DefinePlugin({ - 'process.env.NODE_ENV': '"production"' - }), - new webpack.LoaderOptionsPlugin({ - minimize: true - }) - ) -} - -module.exports = webConfig