refs #901 Stop to specify libraryTarget for renderer in webpack

This commit is contained in:
AkiraFukushima 2019-11-26 23:03:24 +09:00
parent d631f1148e
commit 41d2841961
1 changed files with 4 additions and 19 deletions

View File

@ -12,23 +12,11 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader') const { VueLoaderPlugin } = require('vue-loader')
/**
* List of node_modules to include in webpack bundle
*
* 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
*/
let whiteListedModules = ['vue']
let rendererConfig = { let rendererConfig = {
devtool: '#cheap-module-eval-source-map', devtool: '#cheap-module-eval-source-map',
entry: { entry: {
renderer: path.join(__dirname, '../src/renderer/main.ts') renderer: path.join(__dirname, '../src/renderer/main.ts')
}, },
externals: [
...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d))
],
module: { module: {
rules: [ rules: [
{ {
@ -147,16 +135,13 @@ let rendererConfig = {
removeAttributeQuotes: true, removeAttributeQuotes: true,
removeComments: true removeComments: true
}, },
nodeModules: process.env.NODE_ENV !== 'production' nodeModules: process.env.NODE_ENV !== 'production' ? path.resolve(__dirname, '../node_modules') : false
? path.resolve(__dirname, '../node_modules')
: false
}), }),
new webpack.HotModuleReplacementPlugin(), new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin() new webpack.NoEmitOnErrorsPlugin()
], ],
output: { output: {
filename: '[name].js', filename: '[name].js',
libraryTarget: 'commonjs2',
path: path.join(__dirname, '../dist/electron') path: path.join(__dirname, '../dist/electron')
}, },
resolve: { resolve: {
@ -164,7 +149,7 @@ let rendererConfig = {
// Same as tsconfig.json // Same as tsconfig.json
'@': path.join(__dirname, '../src/renderer'), '@': path.join(__dirname, '../src/renderer'),
'~': path.join(__dirname, '../'), '~': path.join(__dirname, '../'),
'vue$': 'vue/dist/vue.esm.js' vue$: 'vue/dist/vue.esm.js'
}, },
extensions: ['.ts', '.js', '.vue', '.json', '.css', '.node'] extensions: ['.ts', '.js', '.vue', '.json', '.css', '.node']
}, },
@ -177,7 +162,7 @@ let rendererConfig = {
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
rendererConfig.plugins.push( rendererConfig.plugins.push(
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"` __static: `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
}) })
) )
} }