-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
webpack.config.js
64 lines (60 loc) · 1.43 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
const { BannerPlugin } = require('webpack');
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
const pkg = require('./package.json');
const rootPath = process.cwd();
const context = path.join(rootPath, 'src');
const outputPath = path.join(rootPath, 'build');
const filename = path.parse(pkg.main).base;
const getCurrentDate = () => {
const today = new Date();
const year = today.getFullYear();
const month = ('0' + (today.getMonth() + 1)).slice(-2);
const date = ('0' + today.getDate()).slice(-2);
return `${year}-${month}-${date}`;
};
const getBanner = () => {
return (
`/*! ${pkg.name} - ${pkg.version} - ` +
`${getCurrentDate()} ` +
`| (c) 2021-2024 ${pkg.author} | ${pkg.homepage} */`
);
};
module.exports = {
mode: 'production',
context,
entry: {
dcmjsDimse: './index.js',
},
target: 'node',
output: {
filename,
library: pkg.name,
libraryTarget: 'umd',
path: outputPath,
umdNamedDefine: true,
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
parallel: true,
terserOptions: {
sourceMap: true,
},
}),
],
},
externals: Object.keys(pkg.dependencies).reduce((acc, cur) => {
acc[cur] = cur;
return acc;
}, new Object()),
plugins: [
new BannerPlugin({
banner: getBanner(),
entryOnly: true,
raw: true,
}),
],
};