-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathwebpack.config.js
100 lines (94 loc) · 2.54 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
const path = require('path')
const webpack = require('webpack')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const plugins = [
new webpack.DefinePlugin({
'process.env': JSON.stringify({
NODE_ENV: process.env.NODE_ENV,
API_URL: process.env.API_URL,
APP_NAME: process.env.APP_NAME,
ASSETS_URL: process.env.ASSETS_URL,
APP_LOGO: process.env.APP_LOGO,
GOOGLE_GEOCODER_KEY: process.env.GOOGLE_GEOCODER_KEY,
WWW_NAME: process.env.WWW_NAME,
WWW_URL: process.env.WWW_URL,
WWW_DOMAIN: process.env.WWW_DOMAIN,
}),
}),
]
const entries = []
if (process.env.ANALYZE) {
plugins.push(new BundleAnalyzerPlugin())
}
if (process.env.NODE_ENV !== 'production') {
entries.push('webpack-hot-middleware/client?noInfo=true&reload=true')
plugins.push(new webpack.HotModuleReplacementPlugin())
}
entries.push(path.join(__dirname, 'browser.js'))
module.exports = {
context: __dirname,
devtool: 'source-map',
entry: entries,
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules[\\/](?!(lighterhtml-plus|domdiff)[\\/]).*/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', {
targets: {
browsers: ["> 0.25%, not dead"]
},
useBuiltIns: 'entry',
corejs: 3,
}]],
plugins: [
'babel-plugin-syntax-dynamic-import',
'@babel/plugin-proposal-object-rest-spread',
]
}
}
},
]
},
optimization: {
splitChunks: {
chunks: 'all',
},
minimizer: [
// we specify a custom UglifyJsPlugin here to get source maps in production
new UglifyJsPlugin({
cache: true,
parallel: true,
uglifyOptions: {
compress: {
pure_funcs: ['console.log', 'console.debug', 'console.group', 'console.groupEnd'],
},
ecma: 6,
mangle: true,
keep_classnames: false,
keep_fnames: false,
},
sourceMap: true,
})
],
},
output: {
path: '/',
filename: '[hash].js',
chunkFilename: '[id].[contenthash].js',
publicPath: '/assets/'
},
resolve: {
alias: {
'lighterhtml': 'lighterhtml-plus',
'viperhtml': 'lighterhtml-plus',
},
},
plugins,
target: 'web',
}