-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathmakeBundle.js
More file actions
43 lines (38 loc) · 824 Bytes
/
makeBundle.js
File metadata and controls
43 lines (38 loc) · 824 Bytes
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
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const inputFile = './component.js';
const outputFile = './dist/omniscient.js';
const outputMinifiedFile = './dist/omniscient.min.js';
function output(filename) {
return {
library: 'omniscient',
filename: filename,
libraryTarget: 'umd',
umdNamedDefine: true
};
}
function config(filename, plugins = []) {
return {
entry: inputFile,
output: output(filename),
externals: {
react: 'React'
},
plugins
};
}
webpack(
[config(outputFile), config(outputMinifiedFile, [new UglifyJSPlugin()])],
(err, stats) => {
if (err) {
console.error(err);
return;
}
console.log(
stats.toString({
chunks: false,
colors: true
})
);
}
);