-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.prod.js
67 lines (60 loc) · 1.79 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
60
61
62
63
64
65
66
67
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const KotlinWebpackPlugin = require('@jetbrains/kotlin-webpack-plugin');
module.exports = merge(common, {
mode: 'production',
output: {
filename: 'js/[name].[chunkhash].js'
},
plugins: [
new CleanWebpackPlugin(['dist', 'kotlin_build']),
new KotlinWebpackPlugin({
src: path.join(__dirname, 'main'),
optimize: true,
verbose: true,
librariesAutoLookup: true
}),
new MiniCssExtractPlugin({
filename: 'css/[name].[chunkhash].css',
}),
new HtmlWebpackPlugin({
template: './asset/index.html',
hash: true,
minify: {
removeComments: true,
collapseWhitespace: true
}
})
],
devtool: 'source-map',
optimization: {
noEmitOnErrors: true,
runtimeChunk: 'single',
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all'
}
}
},
minimize: true,
minimizer: [
new UglifyJsPlugin({
sourceMap: true,
uglifyOptions: {
compress: {
drop_console: true,
warnings: true
}
}
})
]
}
});