-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.prod.js
94 lines (91 loc) · 2.17 KB
/
webpack.config.prod.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
/* eslint-disable max-len */
var path = require('path');
var webpack = require('webpack');
var merge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var baseConfig = require('./webpack.config.base');
var TerserPlugin = require('terser-webpack-plugin');
// var CheckNodeEnv = require('./scripts/CheckNodeEnv');
const PATHS = {
app: path.join(__dirname, './app/index.js'),
build: path.join(__dirname, '/build/')
}
module.exports = merge.smart(baseConfig, {
target: 'electron-main',
entry: PATHS.app,
output: {
path: PATHS.build,
publicPath: PATHS.build,
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.global\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
publicPath: './',
use: {
loader: 'style-loader',
options: {
minimize: true,
publicPath: './'
}
}
})
},
{
test: /.(css)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 2,
sourceMap: false
}
},
{
loader: 'resolve-url-loader',
options: {
engine: 'rework'
}
}
]
}
]
},
resolve: {
modules: ['node_modules']
},
optimization: {
minimizer: [new TerserPlugin({
terserOptions: {
compress: {},
extractComments: true,
ie8: false,
keep_fnames: false,
mangle: true,
nameCache: null,
output: null,
parse: {},
toplevel: false,
warnings: false
}
})]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new ExtractTextPlugin({
filename: 'style.css'
}),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'style.css'
})
]
});