1'use strict';
2
3const _ = require('lodash');
4const async = require('async');
5const path = require('path');
6const webpack = require('webpack');
7
8const file = require('../common/file');
9const util = require('../common/util');
10
11const basePath = path.join(__dirname, '..', '..');
12const distPath = path.join(basePath, 'dist');
13const fpPath = path.join(basePath, 'fp');
14const filename = 'lodash.fp.js';
15
16const 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
30const 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 */
48function build() {
49  async.series([
50    _.partial(webpack, mappingConfig),
51    _.partial(webpack, fpConfig),
52    file.min(path.join(distPath, filename))
53  ], util.pitch);
54}
55
56build();
57