-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.prod.js
54 lines (53 loc) · 1.82 KB
/
webpack.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
const { merge } = require('webpack-merge');
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const common = require('./webpack.common.js');
const pkg = require('./package.json');
const libraryName = pkg.name;
module.exports = merge(common, {
entry: './client/src/index.js',
output: {
path: path.join(__dirname, 'client/dist'),
filename: 'bundle.js',
library: libraryName,
libraryTarget: 'umd',
publicPath: 'client/dist/',
umdNamedDefine: true
},
mode: 'production',
devtool: 'source-map',
// see https://webpack.js.org/configuration/optimization/
optimization: {
minimizer: [new OptimizeCSSAssetsPlugin({})]
},
module: {
rules: [
{
test: /\.(scss|sass|css)$/,
// only use MiniCssExtractPlugin in production and without style-loader
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
'sass-loader'
]
}
]
},
plugins: [
// new BundleAnalyzerPlugin(),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: 'dist/*.*'
}),
// Mini CSS Extract plugin extracts CSS into separate files.
// It creates a CSS file per JS file which contains CSS.
// It supports On-Demand-Loading of CSS and SourceMaps.
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css'
})
]
});