gulpfile.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. @license
  3. Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
  4. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
  5. The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
  6. The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
  7. Code distributed by Google as part of the polymer project is also
  8. subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
  9. */
  10. const gulp = require('gulp');
  11. const rename = require('gulp-rename');
  12. const replace = require('gulp-replace');
  13. const del = require('del');
  14. /**
  15. * Cleans the prpl-server build in the server directory.
  16. */
  17. gulp.task('prpl-server:clean', () => {
  18. return del('server/build');
  19. });
  20. /**
  21. * Copies the prpl-server build to the server directory while renaming the
  22. * node_modules directory so services like App Engine will upload it.
  23. */
  24. gulp.task('prpl-server:build', () => {
  25. const pattern = 'node_modules';
  26. const replacement = 'node_assets';
  27. return gulp.src('build/**')
  28. .pipe(rename(((path) => {
  29. path.basename = path.basename.replace(pattern, replacement);
  30. path.dirname = path.dirname.replace(pattern, replacement);
  31. })))
  32. .pipe(replace(pattern, replacement))
  33. .pipe(gulp.dest('server/build'));
  34. });
  35. gulp.task('prpl-server', gulp.series(
  36. 'prpl-server:clean',
  37. 'prpl-server:build'
  38. ));