| 1 |
'use strict'; |
| 2 |
|
| 3 |
const _ = require('lodash'); |
| 4 |
const async = require('async'); |
| 5 |
const path = require('path'); |
| 6 |
const webpack = require('webpack'); |
| 7 |
|
| 8 |
const file = require('../common/file'); |
| 9 |
const util = require('../common/util'); |
| 10 |
|
| 11 |
const basePath = path.join(__dirname, '..', '..'); |
| 12 |
const distPath = path.join(basePath, 'dist'); |
| 13 |
const fpPath = path.join(basePath, 'fp'); |
| 14 |
const filename = 'lodash.fp.js'; |
| 15 |
|
| 16 |
const fpConfig = { |
| 17 |
'entry': path.join(fpPath, '_convertBrowser.js'), |
| 18 |
'output': { |
| 19 |
'path': distPath, |
| 20 |
'filename': filename, |
| 21 |
'library': 'fp', |
| 22 |
'libraryTarget': 'umd' |
| 23 |
}, |
| 24 |
'plugins': [ |
| 25 |
new webpack.optimize.OccurenceOrderPlugin, |
| 26 |
new webpack.optimize.DedupePlugin |
| 27 |
] |
| 28 |
}; |
| 29 |
|
| 30 |
const mappingConfig = { |
| 31 |
'entry': path.join(fpPath, '_mapping.js'), |
| 32 |
'output': { |
| 33 |
'path': distPath, |
| 34 |
'filename': 'mapping.fp.js', |
| 35 |
'library': 'mapping', |
| 36 |
'libraryTarget': 'umd' |
| 37 |
} |
| 38 |
}; |
| 39 |
|
| 40 |
/*----------------------------------------------------------------------------*/ |
| 41 |
|
| 42 |
/** |
| 43 |
* Creates browser builds of the FP converter and mappings at the `target` path. |
| 44 |
* |
| 45 |
* @private |
| 46 |
* @param {string} target The output directory path. |
| 47 |
*/ |
| 48 |
function build() { |
| 49 |
async.series([ |
| 50 |
_.partial(webpack, mappingConfig), |
| 51 |
_.partial(webpack, fpConfig), |
| 52 |
file.min(path.join(distPath, filename)) |
| 53 |
], util.pitch); |
| 54 |
} |
| 55 |
|
| 56 |
build(); |