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.

86 lines
2.3 KiB

  1. /*******************************
  2. Build Task
  3. *******************************/
  4. let
  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').default,
  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. {series, parallel} = gulp,
  32. buildJavascript
  33. ;
  34. // add internal tasks (concat release)
  35. require('../collections/internal')(gulp);
  36. buildJavascript = function(callback) {
  37. let
  38. stream,
  39. compressedStream,
  40. uncompressedStream
  41. ;
  42. console.info('Building Javascript');
  43. if( !install.isSetup() ) {
  44. console.error('Cannot build files. Run "gulp install" to set-up Semantic');
  45. return;
  46. }
  47. // copy source javascript
  48. return gulp.src(source.definitions + '/**/' + globs.components + '.js')
  49. .pipe(plumber())
  50. .pipe(flatten())
  51. .pipe(replace(comments.license.in, comments.license.out))
  52. .pipe(gulp.dest(output.uncompressed))
  53. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  54. .pipe(print(log.created))
  55. .pipe(uglify(settings.uglify))
  56. .pipe(rename(settings.rename.minJS))
  57. .pipe(gulp.dest(output.compressed))
  58. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  59. .pipe(print(log.created))
  60. .on('end', function() {
  61. gulp.start('package compressed js');
  62. gulp.start('package uncompressed js');
  63. callback();
  64. })
  65. ;
  66. };
  67. /* Export with Metadata */
  68. buildJavascript.displayName = 'build-javascript';
  69. buildJavascript.description = 'Builds all javascript from source';
  70. module.exports = series(buildJavascript);