BVB Source Codes

reactide Show bundle.js Source code

Return Download reactide: download bundle.js Source code - Download reactide Source code - Type:.js
  1. 'use strict';
  2.  
  3. var fs = require('fs')
  4.   , path = require('path')
  5.   , browserify = require('browserify')
  6.   , uglify = require('uglify-js');
  7.  
  8. var pkg = process.argv[2]
  9.   , standalone = process.argv[3]
  10.   , compress = process.argv[4];
  11.  
  12. var packageDir = path.join(__dirname, '..');
  13. if (pkg != '.') packageDir = path.join(packageDir, 'node_modules', pkg);
  14.  
  15. var json = require(path.join(packageDir, 'package.json'));
  16.  
  17. var distDir = path.join(__dirname, '..', 'dist');
  18. if (!fs.existsSync(distDir)) fs.mkdirSync(distDir);
  19.  
  20. var bOpts = {};
  21. if (standalone) bOpts.standalone = standalone;
  22.  
  23. browserify(bOpts)
  24. .require(path.join(packageDir, json.main), {expose: json.name})
  25. .bundle(function (err, buf) {
  26.   if (err) {
  27.     console.error('browserify error:', err);
  28.     process.exit(1);
  29.   }
  30.  
  31.   var outputFile = path.join(distDir, json.name);
  32.   var outputBundle = outputFile + '.bundle.js';
  33.   fs.writeFileSync(outputBundle, buf);
  34.   var uglifyOpts = {
  35.     warnings: true,
  36.     compress: {},
  37.     output: {
  38.       preamble: '/* ' + json.name + ' ' + json.version + ': ' + json.description + ' */'
  39.     }
  40.   };
  41.   if (compress) {
  42.     var compressOpts = compress.split(',');
  43.     for (var i=0; i<compressOpts.length; ++i) {
  44.       var pair = compressOpts[i].split('=');
  45.       uglifyOpts.compress[pair[0]] = pair.length < 1 || pair[1] != 'false';
  46.     }
  47.   }
  48.   if (standalone) uglifyOpts.outSourceMap = json.name + '.min.js.map';
  49.  
  50.   var result = uglify.minify(outputBundle, uglifyOpts);
  51.   fs.writeFileSync(outputFile + '.min.js', result.code);
  52.   if (result.map) fs.writeFileSync(outputFile + '.min.js.map', result.map);
  53.   if (!standalone) fs.unlinkSync(outputBundle);
  54. });
  55.  
downloadbundle.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top