forked from ringcentral/ringcentral-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
87 lines (78 loc) · 2.86 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
83
84
85
86
87
(function() {
var webpack = require('webpack'),
externals = [
{'resumer': createExternal('resumer')},
{'mocha': createExternal('mocha')},
{'chai': createExternal('chai', 'chai', 'chai')},
{'sinon': createExternal('sinon', 'sinon', 'sinon')},
{'sinon-chai': createExternal('sinon-chai', 'sinon-chai')}
],
bundleExternals = [
{'pubnub': createExternal('pubnub', 'pubnub')},
{'es6-promise': createExternal('es6-promise')},
{'node-fetch': createExternal('node-fetch')}
];
function createExternal(cjs, amd, root) {
var ext = {};
if (cjs) ext['commonjs'] = cjs;
if (cjs) ext['commonjs2'] = cjs;
if (amd) ext['amd'] = amd;
if (root) ext['root'] = root;
return ext;
}
function extendConfig(conf) {
var config = {
context: __dirname,
debug: true,
devtool: '#source-map',
output: {
library: ['RingCentral', 'SDK'],
libraryTarget: 'umd',
path: __dirname + '/build',
publicPath: '/build/',
sourcePrefix: '',
filename: "[name].js",
chunkFilename: "[id].chunk.js"
},
resolve: {
extensions: ['', '.js'],
alias: {
'pubnub': require.resolve('./bower_components/pubnub/web/pubnub.js'),
'node-fetch': require.resolve('./bower_components/fetch/fetch.js'),
'es6-promise': require.resolve('./bower_components/es6-promise/promise.js')
}
},
module: {
loaders: [
{test: /\.js$/, loaders: ['babel-loader?cacheDirectory'], exclude: /node_modules|bower_components/} //TODO: &optional[]=runtime
]
},
node: {
Buffer: false,
process: false,
timers: false
}
};
Object.keys(conf).forEach(function(key) {
config[key] = conf[key];
});
return config;
}
module.exports = [
extendConfig({
entry: {'ringcentral': ['./src/SDK.js']},
externals: externals.concat(bundleExternals)
}),
extendConfig({
entry: {'ringcentral-bundle': ['./src/SDK.js']},
externals: externals
}),
extendConfig({
entry: {'tests/ringcentral-tests': ['./src/test/glob.js']},
externals: externals.concat(bundleExternals).concat([
{'../SDK': createExternal('../ringcentral', '../ringcentral', ['RingCentral', 'SDK'])},
{'./SDK': createExternal('../ringcentral', '../ringcentral', ['RingCentral', 'SDK'])}
])
})
];
})();