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