-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.js
59 lines (57 loc) · 2 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
55
56
57
58
59
const path = require('path');
const { merge } = require('webpack-merge');
const commonConfig = require('./webpack.common.js');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const config = (env = {}) => {
return merge(commonConfig({
mode: 'production',
...env
}),{
mode: 'production',
devtool: 'source-map',
module: {
rules: [
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 0,
sourceMap: true,
import: false,
modules: false
}
}
]
}
]
},
plugins: [
new ForkTsCheckerWebpackPlugin(),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: '../bundle-report.html',
openAnalyzer: false
}),
new CleanWebpackPlugin(),
new MiniCssExtractPlugin({
filename: "[name].[contenthash].bundle.css",
chunkFilename: "[id].[contenthash].css"
}),
new CopyWebpackPlugin({
patterns: [{
context: path.resolve(__dirname, 'data'),
from: '**/*',
to: path.join(env.outpath || path.resolve(__dirname, "dist"), 'data')
}]
})
]
});
}
module.exports = config;