Matteo Scandolo | 280dcd3 | 2016-05-16 09:59:38 -0700 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
| 3 | var _ = require('lodash'), |
| 4 | async = require('async'), |
| 5 | path = require('path'), |
| 6 | webpack = require('webpack'); |
| 7 | |
| 8 | var file = require('../common/file'); |
| 9 | |
| 10 | var basePath = path.join(__dirname, '..', '..'), |
| 11 | distPath = path.join(basePath, 'dist'), |
| 12 | fpPath = path.join(basePath, 'fp'), |
| 13 | filename = 'lodash.fp.js'; |
| 14 | |
| 15 | var fpConfig = { |
| 16 | 'entry': path.join(fpPath, '_convertBrowser.js'), |
| 17 | 'output': { |
| 18 | 'path': distPath, |
| 19 | 'filename': filename, |
| 20 | 'library': 'fp', |
| 21 | 'libraryTarget': 'umd' |
| 22 | }, |
| 23 | 'plugins': [ |
| 24 | new webpack.optimize.OccurenceOrderPlugin, |
| 25 | new webpack.optimize.DedupePlugin |
| 26 | ] |
| 27 | }; |
| 28 | |
| 29 | var mappingConfig = { |
| 30 | 'entry': path.join(fpPath, '_mapping.js'), |
| 31 | 'output': { |
| 32 | 'path': distPath, |
| 33 | 'filename': 'mapping.fp.js', |
| 34 | 'library': 'mapping', |
| 35 | 'libraryTarget': 'umd' |
| 36 | } |
| 37 | }; |
| 38 | |
| 39 | /*----------------------------------------------------------------------------*/ |
| 40 | |
| 41 | function onComplete(error) { |
| 42 | if (error) { |
| 43 | throw error; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | function build() { |
| 48 | async.series([ |
| 49 | _.partial(webpack, mappingConfig), |
| 50 | _.partial(webpack, fpConfig), |
| 51 | file.min(path.join(distPath, filename)) |
| 52 | ], onComplete); |
| 53 | } |
| 54 | |
| 55 | build(); |