-
Notifications
You must be signed in to change notification settings - Fork 8
/
webpack.config.js
82 lines (74 loc) · 1.94 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
75
76
77
78
79
80
81
82
const webpack = require('webpack')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const fs = require('fs')
const modules = [
'BaseComponent',
'Component',
'loadComponents',
'createInstance',
'removeComponents',
'destroyInstance',
'getComponentFromElement',
'eventbus',
'config',
];
const defaultConfig = {
mode: "production",
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['es2015', 'stage-0'],
}
}
]
},
optimization: {
minimizer: [
// we specify a custom UglifyJsPlugin here to get source maps in production
new UglifyJsPlugin({
uglifyOptions: {
compress: false,
ecma: 6,
mangle: true
},
include: /\.min\.js$/
})
]
}
}
const baseConfig = Object.assign({}, defaultConfig, {
entry: {
"gia": "./webpackEntries/entry.js",
"gia.min": "./webpackEntries/entry.js",
},
output: {
path: __dirname + "/dist/",
library: "gia",
libraryTarget: "umd",
filename: "[name].js",
},
})
function createModulesConfig(modulesName) {
let config = Object.assign({}, defaultConfig, {
entry: {},
output: {
path: __dirname + "/dist",
library: modulesName,
libraryTarget: "umd",
filename: "[name].js",
},
})
config.entry[modulesName] = `./webpackEntries/${modulesName}.js`
config.entry[modulesName + ".min"] = `./webpackEntries/${modulesName}.js`
return config;
}
let configsArray = []
configsArray.push(baseConfig)
modules.forEach(item => {
configsArray.push(createModulesConfig(item))
})
module.exports = configsArray