gulpfile.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. 'use strict';
  2. var gulp = require('gulp');
  3. var util = require('gulp-util');
  4. var sass = require('gulp-sass');
  5. var watch = require('gulp-watch');
  6. var autoprefixer = require('gulp-autoprefixer');
  7. var jsmin = require('gulp-jsmin');
  8. var cssmin = require('gulp-cssmin');
  9. var rename = require('gulp-rename');
  10. var mainBowerFiles = require('main-bower-files');
  11. function handleError(err) {
  12. console.log(err.toString());
  13. }
  14. var config = {
  15. assetsDir : './assets',
  16. production: !!util.env.production
  17. }
  18. gulp.task('scripts', function () {
  19. gulp.src('./assets/scripts/main.js')
  20. .pipe(config.production ? jsmin() : util.noop())
  21. .pipe(rename({suffix: '.min'}))
  22. .pipe(gulp.dest('./assets/dist/scripts/'));
  23. });
  24. gulp.task('styles', function () {
  25. gulp.src('./assets/styles/app.scss')
  26. .pipe(sass().on('error', sass.logError))
  27. .pipe(autoprefixer({
  28. browsers: ['last 2 versions'],
  29. cascade: false
  30. })).on('error', handleError)
  31. .pipe(config.production ? cssmin() : util.noop())
  32. .pipe(rename({suffix: '.min'}))
  33. .pipe(gulp.dest('./assets/dist/styles/'));
  34. });
  35. gulp.task('bower', function() {
  36. gulp.src(mainBowerFiles({
  37. "overrides":{
  38. "history.js":{
  39. "main":"./scripts/bundled/html4+html5/jquery.history.js"
  40. },
  41. "jquery":{
  42. "ignore":true
  43. },
  44. "overlayScrollbars":{
  45. "main":[
  46. "./js/jquery.overlayScrollbars.min.js",
  47. "./css/OverlayScrollbars.min.css"
  48. ]
  49. }
  50. }
  51. }))
  52. .pipe(gulp.dest('./assets/dist/bower/'));
  53. });
  54. // default gulp task
  55. gulp.task('default', ['bower', 'scripts', 'styles'], function() {
  56. gulp.watch('./assets/styles/*.scss', ['styles']);
  57. gulp.watch('./assets/styles/base/*.scss', ['styles']);
  58. gulp.watch('./assets/scripts/*.js', ['scripts']);
  59. });