gulpTasks-watch.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Import Dependencies.
  2. var gulp = require("gulp");
  3. var webpack = require('webpack');
  4. var webpackStream = require("webpack-stream");
  5. var processShaders = require("../helpers/gulp-processShaders");
  6. var uncommentShaders = require('../helpers/gulp-removeShaderComments');
  7. // Read the full config.
  8. var config = require("../config.json");
  9. // Keep for reference for a bit might cccome back pretty soon.
  10. // /**
  11. // * Watch ts files from typescript .
  12. // * Hack into the cli :-)
  13. // */
  14. // gulp.task("srcTscWatch", function() {
  15. // // Reuse The TSC CLI from gulp to enable -w.
  16. // process.argv[2] = "-w";
  17. // process.argv[3] = "-p";
  18. // process.argv[4] = "../../src/tsconfig.json";
  19. // require("../../../node_modules/typescript/lib/tsc.js");
  20. // return Promise.resolve();
  21. // });
  22. /**
  23. * Watch ts files and fire repective tasks.
  24. */
  25. gulp.task("watch", function startWatch() {
  26. var tasks = [];
  27. config.modules.map(function(module) {
  28. var settings = config[module].build;
  29. if (settings && settings.webpack) {
  30. for (var index = 0; index < config[module].libraries.length; index++) {
  31. var library = config[module].libraries[index];
  32. if (library.preventLoadLibrary) {
  33. continue;
  34. }
  35. let wpconfig = require(settings.webpack);
  36. // watch on.
  37. wpconfig.watch = true;
  38. // dev mode and absolute path sourcemaps for debugging
  39. wpconfig.mode = "development";
  40. wpconfig.output.devtoolModuleFilenameTemplate = "[absolute-resource-path]";
  41. //config.stats = "minimal";
  42. var outputDirectory = config.build.tempDirectory + settings.distOutputDirectory;
  43. tasks.push(webpackStream(wpconfig, webpack).pipe(gulp.dest(outputDirectory)))
  44. tasks.push(gulp.src(settings.srcDirectory + "**/*.fx")
  45. .pipe(uncommentShaders())
  46. .pipe(processShaders(config[module].isCore))
  47. );
  48. tasks.push(
  49. gulp.watch(settings.srcDirectory + "**/*.fx", { interval: 1000 }, function() {
  50. console.log(library.output + ": Shaders.");
  51. gulp.src(settings.srcDirectory + "**/*.fx")
  52. .pipe(uncommentShaders())
  53. .pipe(processShaders(config[module].isCore));
  54. })
  55. );
  56. }
  57. }
  58. });
  59. return Promise.resolve();
  60. });