build-dist.js 1.3 KB

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