-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_dll.js
58 lines (54 loc) · 1.56 KB
/
build_dll.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
const path = require('path');
const webpack = require('webpack');
const UglifyPlugin = require('uglifyjs-webpack-plugin');
const ProgressPlugin = require('progress-bar-webpack-plugin');
const entrys = require('./config.js').dlls;
const getDllObj = ({ key, list, depends }) => {
const config = {
entry: { [key]: list },
output: {
path: path.resolve(__dirname, `./dll/${key}`),
filename: `${key}.js`,
library: key
},
devtool: 'source-map',
plugins: [
new webpack.DllPlugin({
path: path.join(__dirname, `./dll/${key}/dll-manifest.json`),
name: key,
}),
new UglifyPlugin(),
new ProgressPlugin(),
]
};
if (depends) {
depends.forEach((itemKey) => {
config.plugins.push(new webpack.DllReferencePlugin({
manifest: require(`./dll/${itemKey}/dll-manifest.json`)
}));
});
}
return config;
};
let i = 0;
(function makeDlls() {
const item = entrys[i];
if (!item) return;
const dll = getDllObj(item);
console.log(`build ${item.key}...`);
const compiler = webpack(dll);
compiler.run((err, stats) => {
if (err) {
return console.error(err);
}
const jsonStats = stats.toJson();
if (jsonStats.errors.length > 0) {
jsonStats.errors.forEach((element) => {
console.log(element);
}, this);
}
i++;
makeDlls();
return 0;
});
}());