gulpfile.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. 'use strict';
  19. // generated on 2014-06-25 using generator-gulp-webapp 0.1.0
  20. var gulp = require('gulp');
  21. // load plugins
  22. var $ = require('gulp-load-plugins')();
  23. gulp.task('styles', function () {
  24. return gulp.src('app/styles/main.css')
  25. .pipe($.autoprefixer('last 1 version'))
  26. .pipe(gulp.dest('.tmp/styles'))
  27. .pipe($.size());
  28. });
  29. gulp.task('html', ['styles'], function () {
  30. var jsFilter = $.filter('**/*.js');
  31. var cssFilter = $.filter('**/*.css');
  32. return gulp.src('app/*.html')
  33. .pipe($.plumber())
  34. .pipe($.useref.assets({searchPath: '{.tmp,app}'}))
  35. .pipe(jsFilter)
  36. .pipe($.uglify())
  37. .pipe(jsFilter.restore())
  38. .pipe(cssFilter)
  39. .pipe(cssFilter.restore())
  40. .pipe($.useref.restore())
  41. .pipe($.useref())
  42. .pipe(gulp.dest('dist'))
  43. .pipe($.size());
  44. });
  45. gulp.task('views', function() {
  46. return gulp.src('app/views/**/*.html')
  47. .pipe(gulp.dest('dist/views'));
  48. });
  49. gulp.task('images', function () {
  50. return gulp.src('app/images/**/*')
  51. .pipe(gulp.dest('dist/images'))
  52. .pipe($.size());
  53. });
  54. gulp.task('fonts', function () {
  55. return $.bowerFiles()
  56. .pipe($.filter('**/*.{eot,svg,ttf,woff}'))
  57. .pipe($.flatten())
  58. .pipe(gulp.dest('dist/fonts'))
  59. .pipe($.size());
  60. });
  61. gulp.task('extras', function () {
  62. return gulp.src(['app/*.*', '!app/*.html'], { dot: true })
  63. .pipe(gulp.dest('dist'));
  64. });
  65. gulp.task('clean', function () {
  66. return gulp.src(['.tmp', 'dist'], { read: false }).pipe($.clean());
  67. });
  68. gulp.task('build', ['html', 'views', 'images', 'fonts', 'extras']);
  69. gulp.task('default', ['clean'], function () {
  70. gulp.start('build');
  71. });