-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.renderer.additions.js
87 lines (79 loc) · 1.89 KB
/
webpack.renderer.additions.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
require('es6-promise').polyfill()
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const isDevelopment = process.env.NODE_ENV === 'development'
var webpackPlugins = [
new webpack.DefinePlugin({
ENV: JSON.stringify(process.env.NODE_ENV || 'production')
}),
new webpack.ExternalsPlugin('commonjs', [
'electron',
'lodash',
'fs',
'path',
'jss',
'highlight.js',
'lzma',
'marked',
'moment',
'datauri'
]),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
]
const configuration = {
entry : {},
module: {
rules: [
{
test: /\.pug$/,
use : 'pug-plain-loader'
}, {
test : /\.html$/,
loader : 'html-loader',
options: {
// Disables attributes processing
attributes: false
}
}
]
},
externals: {
'aws-sdk': 'aws-sdk'
},
plugins: webpackPlugins
}
const addChunk = (entry, renderer, addHtmlFile) => {
if (isDevelopment) {
configuration.entry[entry] = [
'css-hot-loader/hotModuleReplacement',
`./src/renderer/${renderer}`
]
} else {
configuration.entry[entry] = `./src/renderer/${renderer}`
}
if (addHtmlFile) {
configuration.plugins.push(new HtmlWebpackPlugin({
'template' : '!!html-loader?minimize=false!dist/.renderer-index-template.html',
'filename' : `${entry}.html`,
'hash' : false,
'inject' : true,
'compile' : true,
'favicon' : false,
'minify' : false,
'cache' : true,
'showErrors' : true,
'chunks' : ['theme', entry],
'excludeChunks' : [],
'chunksSortMode': 'auto',
'meta' : {},
'title' : `Chunk ${entry}`,
'xhtml' : false
}))
}
}
addChunk('theme', 'styles.js', false)
addChunk('app', 'app.js', true)
addChunk('popup', 'popup.js', true)
addChunk('background', 'worker.js', true)
addChunk('bbrowser', 'bbrowser.js', true)
module.exports = configuration