gulpfile.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. var gulp = require('gulp');
  2. var gutil = require('gulp-util');
  3. var bower = require('bower');
  4. var concat = require('gulp-concat');
  5. var sass = require('gulp-sass');
  6. var minifyCss = require('gulp-minify-css');
  7. var rename = require('gulp-rename');
  8. var sh = require('shelljs');
  9. var uglify = require("gulp-uglify");
  10. var stripDebug = require('gulp-strip-debug');
  11. var ngAnnotate = require('gulp-ng-annotate');
  12. var paths = {
  13. sass: ['./scss/**/*.scss'],
  14. starter: ['./www/js/start/config.js','./www/js/start/controller.js','./www/js/start/directive.js','./www/js/start/factory.js','./www/js/start/filter.js']
  15. };
  16. gulp.task('default', ['sass', 'starter']);
  17. gulp.task('starter', function () {
  18. gulp.src(paths.starter)
  19. .pipe(concat('starter.js'))
  20. .pipe(gulp.dest('./www/js'))
  21. .pipe(ngAnnotate())
  22. .pipe(stripDebug())
  23. .pipe(uglify())
  24. .pipe(rename({extname: '.min.js'}))
  25. .pipe(gulp.dest('./www/js/'));
  26. });
  27. gulp.task('sass', function (done) {
  28. gulp.src(['./scss/ionic.app.scss', './scss/linker.scss'])
  29. .pipe(sass())
  30. .on('error', sass.logError)
  31. .pipe(gulp.dest('./www/css/'))
  32. .pipe(minifyCss({
  33. keepSpecialComments: 0
  34. }))
  35. .pipe(rename({extname: '.min.css'}))
  36. .pipe(gulp.dest('./www/css/'))
  37. .on('end', done);
  38. });
  39. gulp.task('watch', function () {
  40. gulp.watch(paths.sass, ['sass']);
  41. gulp.watch(paths.starter, ['starter']);
  42. });
  43. gulp.task('install', ['git-check'], function () {
  44. return bower.commands.install()
  45. .on('log', function (data) {
  46. gutil.log('bower', gutil.colors.cyan(data.id), data.message);
  47. });
  48. });
  49. gulp.task('git-check', function (done) {
  50. if (!sh.which('git')) {
  51. console.log(
  52. ' ' + gutil.colors.red('Git is not installed.'),
  53. '\n Git, the version control system, is required to download Ionic.',
  54. '\n Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.',
  55. '\n Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
  56. );
  57. process.exit(1);
  58. }
  59. done();
  60. });