-
Notifications
You must be signed in to change notification settings - Fork 19
/
webpack.config.js
74 lines (61 loc) · 1.62 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
65
66
67
68
69
70
71
72
73
74
var path = require('path');
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
// assets.js
var assets = require('./js/assets');
var copiers = [];
function make_spec(key, asset) {
var spec = {};
if (typeof asset === 'object') {
var source = asset['source'];
var asset_type = asset['type'];
var dest = null;
if (asset.hasOwnProperty('dest')) {
dest = asset['dest'];
} else {
dest = path.basename(source);
}
spec = {
from: path.resolve(__dirname, `./node_modules/${source}`),
to: path.resolve(__dirname, `./${key}/components/${dest}`)
};
if (asset_type === 'dir') {
spec['toType'] = 'dir';
}
} else {
spec = {
from: path.resolve(__dirname, `./node_modules/${asset}`),
to: path.resolve(__dirname, `./${key}/components/`)
};
}
return spec;
}
Object.keys(assets).forEach(function(key) {
if (assets[key].length > 0) {
assets[key].map(asset => {
var spec = make_spec(key, asset);
var copier = new CopyWebpackPlugin({
patterns: [
spec
]
});
copiers.push(copier);
});
}
});
module.exports = {
performance: {
maxAssetSize: 1000000
},
optimization: {
minimize: false
},
entry: {
'index': __dirname + '/js/portal.js'
},
output: {
path: __dirname + '/js/components/',
filename: '[name].bundle.js'
},
plugins: copiers
};