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.

gulpfile.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. const gulp = require('gulp');
  2. const imagemin = require('gulp-imagemin');
  3. const uglify = require('gulp-uglify');
  4. const sass = require('gulp-sass');
  5. const concat = require('gulp-concat');
  6. /*
  7. * Toplevelfunction
  8. * gulp.task
  9. * gulp.src
  10. * gulp.dest
  11. * gulp.watch
  12. */
  13. // Logs Message
  14. gulp.task('message', function () {
  15. return console.log('Gulp is running...');
  16. });
  17. // Copy All HTML files
  18. gulp.task('copyHtml', function () {
  19. gulp.src('app/*.html')
  20. .pipe(gulp.dest('dist'));
  21. });
  22. // Optimize Images
  23. gulp.task('imageMin', () =>
  24. gulp.src('app/img/*')
  25. .pipe(imagemin())
  26. .pipe(gulp.dest('dist/images'))
  27. );
  28. // Minify JS
  29. gulp.task('minify', function () {
  30. gulp.src('app/scripts/*.js')
  31. .pipe(uglify())
  32. .pipe(gulp.dest('dist/js'));
  33. });
  34. // Compile Sass
  35. gulp.task('sass', function () {
  36. gulp.src('app/sass/*.scss')
  37. .pipe(sass().on('error', sass.logError))
  38. .pipe(gulp.dest('dist/css'));
  39. });
  40. // Scripts
  41. gulp.task('scripts', function () {
  42. gulp.src('app/scripts/*.js')
  43. .pipe(concat('app.js'))
  44. .pipe(uglify())
  45. .pipe(gulp.dest('dist/js'));
  46. });
  47. gulp.task('default', ['message', 'copyHtml', 'imageMin', 'sass', 'scripts']);
  48. /*
  49. gulp.task('watch', function () {
  50. gulp.watch('app/scripts/*.js', ['scripts']);
  51. gulp.watch('app/img/*', ['imageMin']);
  52. gulp.watch('app/sass/*.scss', ['sass']);
  53. gulp.watch('app/*.html', ['copyHtml']);
  54. });*/