-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
73 lines (61 loc) · 1.81 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
"use strict";
const path = require('path');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const package_json = require("./package.json");
const ver = package_json.version;
const devMode = process.env.NODE_ENV !== 'production';
const PRJ_PATH = path.resolve(
__dirname, 'django_comments_ink', 'static', 'django_comments_ink'
);
const plugins = [
new webpack.ProgressPlugin(),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [
`!*${ver}*.js`
]
}),
];
module.exports = {
mode: devMode ? 'development' : 'production',
context: __dirname,
devtool: 'source-map',
entry: {
dci: path.resolve(PRJ_PATH, "js/index.js")
},
output: {
path: path.resolve(PRJ_PATH, "dist"),
filename: devMode ? `[name]-${ver}.js` : `[name]-${ver}.min.js`
},
optimization: {
minimize: !devMode,
minimizer: [
new TerserPlugin({
terserOptions: {
parse: {
ecma: 8
},
compress: {
ecma: 5,
warnings: false,
comparisons: false,
inline: 2,
drop_debugger: !devMode
},
mangle: {
safari10: true
},
keep_classnames: !devMode,
keep_fnames: !devMode,
output: {
ecma: 5,
comments: false,
ascii_only: true
}
}
}),
]
},
plugins: plugins,
};