Skip to content

Commit

Permalink
updated dependencies. refactored setup for latest webpack. merged ci.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Mulholland committed Oct 8, 2018
1 parent a629db7 commit e332f5e
Show file tree
Hide file tree
Showing 106 changed files with 4,851 additions and 25,185 deletions.
6 changes: 2 additions & 4 deletions .electron-vue/webpack.main.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
'use strict'

process.env.BABEL_ENV = 'main'

// process.traceDeprecation = true
const path = require('path')
const {dependencies} = require('../package.json')
const webpack = require('webpack')

const BabiliWebpackPlugin = require('babili-webpack-plugin')
const FixDefaultImportPlugin = require('webpack-fix-default-import-plugin')

let mainConfig = {
entry: {
Expand Down Expand Up @@ -55,8 +54,7 @@ let mainConfig = {
]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new FixDefaultImportPlugin()
new webpack.NoEmitOnErrorsPlugin()
],
target: 'electron-main'
}
Expand Down
95 changes: 25 additions & 70 deletions .electron-vue/webpack.renderer.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
'use strict'

process.env.BABEL_ENV = 'renderer'

// process.traceDeprecation = true
const path = require('path')
const { dependencies } = require('../package.json')
const {dependencies} = require('../package.json')
const webpack = require('webpack')

const BabiliWebpackPlugin = require('babili-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FixDefaultImportPlugin = require('webpack-fix-default-import-plugin')
const {VueLoaderPlugin} = require('vue-loader')

/**
Expand All @@ -19,40 +18,6 @@ const {VueLoaderPlugin} = require('vue-loader')
* Required for specific packages like Vue UI libraries
* that provide pure *.vue files that need compiling
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/webpack-configurations.html#white-listing-externals
*
*
* // optimization: {
// splitChunks: {
// chunks: 'all'
// },
// cacheGroups: {
// styles: {
// name: 'styles',
// test: /\.s?css$/,
// chunks: 'all',
// minChunks: 1,
// reuseExistingChunk: true,
// enforce: true,
// },
// }
// },
optimization: {
minimize: false,
runtimeChunk: {
name: 'vendor'
},
splitChunks: {
cacheGroups: {
default: false,
commons: {
test: /node_modules/,
name: "vendor",
chunks: "initial",
minSize: 1
}
}
}
},
*/
let whiteListedModules = ['vue']
const defaultMinify = {
Expand All @@ -61,21 +26,19 @@ const defaultMinify = {
removeComments: true
}

const sourceMap = process.env.NODE_ENV === 'development'

const defaultNodeModules = process.env.NODE_ENV !== 'production'
? path.resolve(__dirname, '../node_modules')
: false

let rendererConfig = {
devtool: sourceMap ? '#cheap-module-eval-source-map' : undefined,
devtool: '#cheap-module-eval-source-map',
entry: {
renderer: path.join(__dirname, '../src/renderer/main.js')
},
externals: [
...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d))
],
optimization: {
optimization: !process.env.KARMA ? {
minimize: false,
runtimeChunk: {
name: 'vendor'
Expand All @@ -99,7 +62,7 @@ let rendererConfig = {
},
}
}
},
} : {},
module: {
rules: [
{
Expand All @@ -116,19 +79,19 @@ let rendererConfig = {
{
test: /\.css$/,
use: [
{
loader:
process.env.NODE_ENV !== 'production' ? 'vue-style-loader' : MiniCssExtractPlugin.loader,
options: {
sourceMap
}
},
{
loader: 'css-loader',
options: {
sourceMap
}
}]
// MiniCssExtractPlugin.loader,
'vue-style-loader',
'css-loader'
]
},
{
test: /\.styl(us)?$/,
use: [
// MiniCssExtractPlugin.loader,
'vue-style-loader',
'css-loader',
'stylus-loader'
]
},
{
test: /\.html$/,
Expand All @@ -153,23 +116,16 @@ let rendererConfig = {
sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1',
scss: 'vue-style-loader!css-loader!sass-loader',
styl: 'vue-style-loader!css-loader!stylus-loader'
// styl: 'MiniCssExtractPlugin.loader!css-loader!stylus-loader'
}
}
}
},
{
test: /\.styl(us)?$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'stylus-loader'
]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
use: {
loader: 'url-loader',
query: {
options: {
limit: 10000,
name: 'imgs/[name]--[folder].[ext]'
}
Expand All @@ -187,7 +143,7 @@ let rendererConfig = {
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
use: {
loader: 'url-loader',
query: {
options: {
limit: 10000,
name: 'fonts/[name]--[folder].[ext]'
}
Expand All @@ -208,8 +164,7 @@ let rendererConfig = {
createHtmlPlugin('openexcel'),
createHtmlPlugin('errors'),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new FixDefaultImportPlugin()
new webpack.NoEmitOnErrorsPlugin()
],
output: {
filename: '[name].js',
Expand All @@ -222,7 +177,7 @@ let rendererConfig = {
'vue$': 'vue/dist/vue.esm.js',
'static': path.resolve(__dirname, '../static')
},
extensions: ['.js', '.vue', '.json', '.css', '.node']
extensions: ['.js', '.vue', '.json', '.css', '.node', '.styl']
},
target: 'electron-renderer'
}
Expand All @@ -239,7 +194,7 @@ function createHtmlPlugin(pageName) {
/**
* Adjust rendererConfig for development settings
*/
if (process.env.NODE_ENV !== 'production') {
if (process.env.NODE_ENV !== 'production' || process.env.KARMA) {
rendererConfig.plugins.push(
new webpack.DefinePlugin({
'__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
Expand All @@ -250,7 +205,7 @@ if (process.env.NODE_ENV !== 'production') {
/**
* Adjust rendererConfig for production settings
*/
if (process.env.NODE_ENV === 'production') {
if (process.env.NODE_ENV === 'production' && !process.env.KARMA) {
rendererConfig.devtool = ''

rendererConfig.plugins.push(
Expand Down
2 changes: 0 additions & 2 deletions .electron-vue/webpack.test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const webpack = require('webpack')
const WebpackShellPlugin = require('webpack-shell-plugin')

const BabiliWebpackPlugin = require('babili-webpack-plugin')
const FixDefaultImportPlugin = require('webpack-fix-default-import-plugin')

let mainTestConfig = {
externals: [nodeExternals()],
Expand Down Expand Up @@ -48,7 +47,6 @@ let mainTestConfig = {
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new FixDefaultImportPlugin(),
],
target: 'electron'
}
Expand Down
Loading

0 comments on commit e332f5e

Please sign in to comment.