-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
121 lines (111 loc) · 2.74 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
'use strict'
const path = require('path')
const { IgnorePlugin, EnvironmentPlugin } = require('webpack')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CspHtmlWebpackPlugin = require('csp-html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const { DefinePlugin } = require('webpack')
const distPath = path.resolve(__dirname)
module.exports = (env, options) => {
if (env.pack) {
console.log('Packing nodegit...')
}
const main = {
entry: [
path.resolve(__dirname, './src/main/main.js')
],
output: {
filename: './main.js',
path: path.resolve(distPath),
devtoolModuleFilenameTemplate: '[absolute-resource-path]'
},
target: 'electron-main',
node: {
__dirname: false
},
module: {
// rules: [
// {
// test: /\.node$/,
// loader: 'node-loader',
// },
// ],
},
plugins: [
new IgnorePlugin(/build\/Debug\/nodegit.node$/i),
new DefinePlugin({
'process.env.BUNDLE_VERSION': JSON.stringify(process.env.npm_package_version)
}),
new EnvironmentPlugin({
NODE_ENV: 'dev',
DEBUG_ENABLED: 'false'
})
],
externals: {
nodegit: 'commonjs nodegit'
}
}
const preload = {
entry: [
path.resolve(__dirname, './src/main/preload.js')
],
node: {
__dirname: false
},
output: {
filename: 'preload.js',
path: path.resolve(distPath)
},
target: 'electron-preload'
}
if (process.env.DEBUG_ENABLED === 'true') console.log('Chrome developer mode, vue-devtools, and extensive logging are enabled')
const rendererPlugins = [
new MiniCssExtractPlugin(),
new VueLoaderPlugin(),
new HtmlWebpackPlugin({
template: 'src/index_template.html',
templateParameters: {
debug: process.env.DEBUG_ENABLED === 'true'
}
})
]
if (options.mode === 'production') {
rendererPlugins.push(
new CspHtmlWebpackPlugin({
'script-src': '',
'style-src': ''
})
)
}
const renderer = {
entry: path.resolve(__dirname, './src/renderer/render-level.js'),
output: {
filename: 'render-level.js',
path: path.join(distPath)
},
node: {
__dirname: false
},
target: 'electron-renderer',
resolve: {
alias: {
vue$: 'vue/dist/vue.runtime.common.js'
}
},
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.vue$/,
loader: 'vue-loader'
}
]
},
plugins: rendererPlugins
}
return [main, preload, renderer]
}