-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.build.config.js
59 lines (56 loc) · 1.49 KB
/
webpack.build.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
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const TerserPlugin = require('terser-webpack-plugin');
const common = require('./webpack.common.config');
const { npm_package_name: name, npm_package_version: version } = process.env;
const [, month, day, year] = new Date().toDateString().split(' ');
const date = `${day}-${month}-${year}`;
const lines = [
` * package: ${name}`,
` * version: ${version}`,
` * published: ${date}`,
];
const endPadding = 8;
const longest = lines.reduce(
(longest, line) => Math.max(longest, line.length),
0
);
const banner =
lines.reduce(
(str, line) => `${str}${line.padEnd(longest + endPadding)}*\n`,
`${'/*'.padEnd(longest + endPadding, '*')}*\n`
) + `${' *'.padEnd(longest + endPadding, '*')}*/\n\n`;
module.exports = () => {
const config = {
...common,
entry: path.resolve(__dirname, 'src', 'components', 'ColorPicker.tsx'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
library: 'color-picker',
libraryTarget: 'umd',
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
terserOptions: {
output: {
comments: false,
preamble: banner,
},
},
}),
],
},
mode: 'none',
externals: [
nodeExternals({
allowlist: ['chroma-js'],
}),
],
plugins: [],
};
return config;
};