forked from interledgerjs/five-bells-condition
-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.parts.js
49 lines (37 loc) · 1.28 KB
/
webpack.parts.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
/* eslint-disable strict, no-console, object-shorthand */
'use strict'
const path = require('path')
const { merge } = require('webpack-merge')
const development = require('./webpack.development.js')
const production = require('./webpack.production.js')
const AddVendorsPlugin = require('./plugins/add-vendors-plugin')
const paths = {
entry: path.resolve(__dirname, 'src/index.js'),
bundle: path.resolve(__dirname, 'dist/browser')
}
const outputs = (base, env, mapping, overrides) => {
const collection = []
const library = 'CryptoConditions'
// const windowLibrary = 'CryptoConditions'
const environment = env === 'production' ? production : development
const ext = env === 'production' ? 'min.js' : 'js'
Object.entries(mapping).forEach(([target, extension]) => {
const filename = `[name].${library}.${extension}.${ext}`
const compiled = {
output: {
filename: filename,
// setting library mess up with export
// library: target === 'window' ? windowLibrary : library,
libraryTarget: target,
path: paths.bundle
},
plugins: [new AddVendorsPlugin(`${library}.${extension}.${ext}`)]
}
collection.push(merge(base, environment, compiled, overrides))
})
return collection
}
module.exports = {
outputs,
paths
}