You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0 KiB

  1. /*******************************
  2. Build Task
  3. *******************************/
  4. var
  5. gulp = require('gulp'),
  6. // node dependencies
  7. console = require('better-console'),
  8. fs = require('fs'),
  9. // gulp dependencies
  10. chmod = require('gulp-chmod'),
  11. flatten = require('gulp-flatten'),
  12. gulpif = require('gulp-if'),
  13. plumber = require('gulp-plumber'),
  14. print = require('gulp-print'),
  15. rename = require('gulp-rename'),
  16. replace = require('gulp-replace'),
  17. uglify = require('gulp-uglify'),
  18. // config
  19. config = require('../config/user'),
  20. tasks = require('../config/tasks'),
  21. install = require('../config/project/install'),
  22. // shorthand
  23. globs = config.globs,
  24. assets = config.paths.assets,
  25. output = config.paths.output,
  26. source = config.paths.source,
  27. banner = tasks.banner,
  28. comments = tasks.regExp.comments,
  29. log = tasks.log,
  30. settings = tasks.settings
  31. ;
  32. // add internal tasks (concat release)
  33. require('../collections/internal')(gulp);
  34. module.exports = function(callback) {
  35. var
  36. stream,
  37. compressedStream,
  38. uncompressedStream
  39. ;
  40. console.info('Building Javascript');
  41. if( !install.isSetup() ) {
  42. console.error('Cannot build files. Run "gulp install" to set-up Semantic');
  43. return;
  44. }
  45. // copy source javascript
  46. gulp.src(source.definitions + '/**/' + globs.components + '.js')
  47. .pipe(plumber())
  48. .pipe(flatten())
  49. .pipe(replace(comments.license.in, comments.license.out))
  50. .pipe(gulp.dest(output.uncompressed))
  51. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  52. .pipe(print(log.created))
  53. .pipe(uglify(settings.uglify))
  54. .pipe(rename(settings.rename.minJS))
  55. .pipe(gulp.dest(output.compressed))
  56. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  57. .pipe(print(log.created))
  58. .on('end', function() {
  59. gulp.start('package compressed js');
  60. gulp.start('package uncompressed js');
  61. callback();
  62. })
  63. ;
  64. };