Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. var gulp = require('gulp');
  2. var uglify = require('gulp-uglify');
  3. var watch = require('gulp-watch');
  4. var concat = require('gulp-concat');
  5. var connect = require('gulp-connect');
  6. var sourcemaps = require('gulp-sourcemaps');
  7. var htmlmin = require('gulp-htmlmin');
  8. var server = require( 'gulp-develop-server' );
  9.  
  10. gulp.task( 'server:start', function() {
  11. server.listen( { path: './server/app.js' } );
  12. });
  13.  
  14. gulp.task( 'server:restart', function() {
  15. console.log('restart');
  16. });
  17.  
  18. gulp.task('connect', function() {
  19. connect.server({
  20. port: 1337,
  21. livereload: true,
  22. root: 'static',
  23. })
  24. });
  25.  
  26. gulp.task('js', function() {
  27. gulp.src(['static/source/matter.js', 'shared/move.js', 'static/source/settings.js', 'static/source/main.js', 'static/source/**/*.js'])
  28. .pipe(sourcemaps.init())
  29. .pipe(uglify().on('error', function(error) {
  30. console.log("[Error in " + error.plugin + " plugin!]");
  31. console.log("message: " + error.message);
  32. console.log("fileName: " + error.fileName);
  33. console.log("lineNumber: " + error.lineNumber);
  34. }))
  35. .pipe(concat('app.min.js'))
  36. .pipe(sourcemaps.write())
  37. .pipe(gulp.dest('static/js'))
  38. .pipe(connect.reload());
  39. })
  40.  
  41. gulp.task('html', function() {
  42. gulp.src('static/html/**/*.html')
  43. .pipe(htmlmin({collapseWhitespace: true}))
  44. .pipe(gulp.dest('static'))
  45. .pipe(connect.reload());
  46. });
  47.  
  48. gulp.task('js-min', function() {
  49. gulp.src(['static/source/matter.js', 'shared/move.js', 'static/source/settings.js', 'static/source/main.js', 'static/source/**/*.js'])
  50. .pipe(uglify().on('error', function(error) {
  51. console.log("[Error in " + error.plugin + " plugin!]");
  52. console.log("message: " + error.message);
  53. console.log("fileName: " + error.fileName);
  54. console.log("lineNumber: " + error.lineNumber);
  55. }))
  56. .pipe(concat('app.min.js'))
  57. .pipe(gulp.dest('static/js'));
  58. });
  59.  
  60. gulp.task('watch', function() {
  61. gulp.watch('static/source/**/*.js', ['js']);
  62. gulp.watch('static/html/**/*.html', ['html']);
  63. gulp.watch('server/**/*', server.restart);
  64. gulp.watch('shared/**/*', server.restart);
  65. });
  66.  
  67. gulp.task('prodactionBuild', ['html', 'js-min']);
  68. gulp.task('default', ['html', 'js', 'connect', 'watch', 'server:start']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement