-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.dependencies.js
28 lines (24 loc) · 1.06 KB
/
webpack.dependencies.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
// Dependency map
const DEPENDENCIES = {
'lodash': {global: '_', src: 'https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js'},
'jquery': {global: 'jQuery', src: 'https://code.jquery.com/jquery-3.2.1.min.js'},
'mousetrap': {global: 'Mousetrap', src: 'https://cdnjs.cloudflare.com/ajax/libs/mousetrap/1.6.1/mousetrap.min.js'},
'pubnub': {global: 'PubNub', src: 'https://cdn.pubnub.com/sdk/javascript/pubnub.4.17.0.min.js'},
'simple-peer': {global: 'SimplePeer', src: 'https://cdnjs.cloudflare.com/ajax/libs/simple-peer/8.1.1/simplepeer.min.js'},
'localforage': {global: 'localforage', src: 'https://cdnjs.cloudflare.com/ajax/libs/localforage/1.5.3/localforage.min.js'},
}
// Filter modules by name
function filter(...modules) {
return modules.map(name => DEPENDENCIES[name])
}
// Get src of given modules
function src(...modules) {
return filter(...modules).map(d => d.src)
}
// Get externals definition
function externals() {
const obj = {}
for (const k in DEPENDENCIES) obj[k] = DEPENDENCIES[k].global
return obj
}
module.exports = {filter, src, externals}