-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathwebpack.config.js
More file actions
53 lines (51 loc) · 1.34 KB
/
webpack.config.js
File metadata and controls
53 lines (51 loc) · 1.34 KB
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
const path = require('path');
const fs = require('fs');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
mode: 'production',
devtool: false,
entry: {
"ulabel": './src/index.js',
"ulabel.min": './src/index.js'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
library : {
name: "ULabel",
type: "commonjs",
export: "default"
}
},
optimization: {
minimize: true, // Enable minimization so minimizers run
minimizer: [
new TerserPlugin({
test: /\.min\.js$/, // Only minify .min.js files
terserOptions: {
compress: {
drop_console: false,
},
format: {
comments: false,
},
},
extractComments: true, // Extract license comments
}),
],
},
plugins: [
// Copy the extracted license file for both builds
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap('CopyLicensePlugin', (compilation) => {
const licenseSource = path.join(__dirname, 'dist', 'ulabel.min.js.LICENSE.txt');
const licenseDest = path.join(__dirname, 'dist', 'ulabel.js.LICENSE.txt');
if (fs.existsSync(licenseSource)) {
fs.copyFileSync(licenseSource, licenseDest);
}
});
}
}
],
};