forked from nasa/earthdata-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic.webpack.config.prod.js
87 lines (84 loc) · 2.23 KB
/
static.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
const path = require('path')
const webpack = require('webpack')
const merge = require('webpack-merge')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const TerserJsPlugin = require('terser-webpack-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const CSSNano = require('cssnano')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const StaticCommonConfig = require('./static.webpack.config.common')
const Config = merge.smartStrategy({
devtool: 'replace',
'module.rules.use': 'prepend'
})(StaticCommonConfig, {
mode: 'production',
devtool: 'cheap-module-source-map',
output: {
filename: '[name].[contenthash].bundle.js',
chunkFilename: '[name].[contenthash].bundle.js',
path: path.resolve(__dirname, 'static/dist'),
publicPath: '/'
},
optimization: {
nodeEnv: 'production',
concatenateModules: true,
minimizer: [
new TerserJsPlugin({
cache: true,
parallel: true,
sourceMap: true,
include: /\.js$/
}),
new OptimizeCSSAssetsPlugin({
cssProcessor: CSSNano,
cssProcessorPluginOptions: {
preset: ['default', { discardComments: { removeAll: true } }]
}
})
],
splitChunks: {
cacheGroups: {
vendor: {
name: 'vendor',
test: /[\\/]node_modules[\\/]/,
chunks: 'all',
maxSize: 500000
},
styles: {
name: 'styles',
test: /\.css$/,
chunks: 'all'
}
}
},
runtimeChunk: true,
sideEffects: true
},
module: {
rules: [
{
test: /\.(css|scss)$/,
exclude: /portals/i,
use: [
{
loader: 'style-loader'
},
{
loader: MiniCssExtractPlugin.loader
}
]
}
]
},
plugins: [
new webpack.HashedModuleIdsPlugin(),
new CleanWebpackPlugin([path.resolve(__dirname, 'static/dist')]),
new MiniCssExtractPlugin({
filename: '[name].[contenthash].min.css',
chunkFilename: '[id].[contenthash].min.css',
})
// new BundleAnalyzerPlugin()
]
})
module.exports = Config