gulpTasks-watchApps.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Import Dependencies.
  2. var gulp = require("gulp");
  3. var webpack = require('webpack');
  4. var webpackStream = require("webpack-stream");
  5. var path = require("path");
  6. // Read the full config.
  7. var config = require("../../Config/config.js");
  8. /**
  9. * Watch ts files and fire repective tasks.
  10. */
  11. gulp.task("watchApps", function startWatch() {
  12. var tasks = [];
  13. config.apps.map(function(module) {
  14. var settings = config[module].computed;
  15. if (!config[module].isCore && settings) {
  16. var wpConfig = require(settings.webpackConfigPath);
  17. // watch on.
  18. wpConfig.watch = true;
  19. // dev mode and absolute path sourcemaps for debugging
  20. wpConfig.mode = "development";
  21. wpConfig.devtool = "nosources-source-map";
  22. // Source Map Remapping for dev tools.
  23. wpConfig.output.devtoolModuleFilenameTemplate = (info) => {
  24. info.resourcePath = path.normalize(info.resourcePath);
  25. if (!path.isAbsolute(info.resourcePath)) {
  26. info.resourcePath = path.join(settings.srcDirectory, info.resourcePath);
  27. }
  28. return `../../../${path.relative(config.computed.rootFolder, info.resourcePath).replace(/\\/g, "/")}`;
  29. };
  30. var outputDirectory = settings.localDevUMDDirectory;
  31. tasks.push(
  32. webpackStream(wpConfig, webpack)
  33. .pipe(gulp.dest(outputDirectory))
  34. );
  35. }
  36. });
  37. return Promise.resolve();
  38. });