Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. /*  ------------------------------------------------------------------------  *\
  4.     REQUIREMENTS
  5. \*  ------------------------------------------------------------------------  */
  6.  
  7. var
  8.     _                   = require('lodash'),
  9.     chalk               = require('chalk'),
  10.     sequence            = require('run-sequence'),
  11.     del                 = require('del');
  12.  
  13.  
  14. ////////////////////////////////////////////////////////////////////////////////
  15.  
  16.  
  17. var
  18.     gulp                = require('gulp'),
  19.     plugins             = require('gulp-load-plugins')(),
  20.     server              = require('./server');
  21.  
  22.  
  23.  
  24.  
  25.  
  26. /*  ------------------------------------------------------------------------  *\
  27.     VARIABLES
  28. \*  ------------------------------------------------------------------------  */
  29.  
  30. var
  31.     pkg                 = require('./package.json'),
  32.     cwd                 = process.cwd(),
  33.     config              = null;
  34.  
  35.  
  36.  
  37.  
  38.  
  39. /*  ------------------------------------------------------------------------  *\
  40.     HTML
  41. \*  ------------------------------------------------------------------------  */
  42.  
  43. gulp.task('compile:html', function (cb) {
  44.     gulp.src(['client/views/**/*.html'])
  45.         .pipe(gulp.dest('build/views'));
  46.  
  47.     gulp.src(['client/*.html'])
  48.         .pipe(gulp.dest('build/'));
  49.  
  50.     cb(null);
  51. });
  52.  
  53.  
  54.  
  55.  
  56.  
  57. /*  ------------------------------------------------------------------------  *\
  58.     JS
  59. \*  ------------------------------------------------------------------------  */
  60.  
  61. gulp.task('compile:js', function (cb) {
  62.     return gulp.src([
  63.             'bower_components/jquery/dist/jquery.js',
  64.             'bower_components/lodash/dist/lodash.compat.js',
  65.  
  66.             'bower_components/angular/angular.js',
  67.             'bower_components/angular-ui-router/release/angular-ui-router.js',
  68.             'bower_components/angular-translate/angular-translate.js',
  69.             'bower_components/angular-mailchimp/angular-mailchimp.js',
  70.  
  71.             'client/js/app.js',
  72.             'client/js/config/*.js',
  73.             'client/js/controllers/*.js',
  74.             'client/js/directives/*.js',
  75.             'client/js/helpers/*.js',
  76.             'client/js/services/*.js'
  77.         ])
  78.         .pipe(plugins.plumber())
  79.         .pipe(plugins.concat('app.min.js'))
  80.         .pipe(plugins.uglify())
  81.         .pipe(gulp.dest('build/js'))
  82.         .pipe(plugins.filesize());
  83. });
  84.  
  85.  
  86.  
  87.  
  88.  
  89. /*  ------------------------------------------------------------------------  *\
  90.     SERVER
  91. \*  ------------------------------------------------------------------------  */
  92.  
  93. gulp.task('serve', function (cb) {
  94.     plugins.nodemon({ script: 'server.js', ext: 'json js', ignore: ['client/*', 'build/*'] })
  95.         .on('restart', function () {
  96.             console.log(chalk.green('✔  Restarted server'));
  97.         });
  98.  
  99.     cb(null);
  100. });
  101.  
  102.  
  103.  
  104.  
  105.  
  106. /*  ------------------------------------------------------------------------  *\
  107.     WATCH
  108. \*  ------------------------------------------------------------------------  */
  109.  
  110. gulp.task('watch', ['serve'], function (cb) {
  111.     plugins.livereload.listen();
  112.  
  113.     gulp.watch(['client/**/*.html'], ['compile:html']);
  114.  
  115.     gulp.watch(['client/**/*.js'], ['compile:js']);
  116.  
  117.     gulp.watch('client/**')
  118.         .on('change', plugins.livereload.changed);
  119.  
  120.     cb(null);
  121. });
  122.  
  123.  
  124.  
  125.  
  126.  
  127. /*  ------------------------------------------------------------------------  *\
  128.     CLEAN
  129. \*  ------------------------------------------------------------------------  */
  130.  
  131. gulp.task('clean:build', function (cb) {
  132.     del(['build'], cb);
  133. });
  134.  
  135.  
  136.  
  137.  
  138.  
  139. /*  ------------------------------------------------------------------------  *\
  140.     DEFAULT
  141. \*  ------------------------------------------------------------------------  */
  142.  
  143. gulp.task('default', function (cb) {
  144.     console.log(chalk.yellow('----------------------------------------------'));
  145.     console.log(chalk.yellow('project: ' + pkg.name));
  146.     console.log(chalk.yellow('version: ' + pkg.version));
  147.     console.log(chalk.yellow('----------------------------------------------'));
  148.  
  149.     gulp.start('dev');
  150. });
  151.  
  152.  
  153.  
  154.  
  155.  
  156. /*  ------------------------------------------------------------------------  *\
  157.     DEVELOPMENT
  158. \*  ------------------------------------------------------------------------  */
  159.  
  160. gulp.task('dev', function (cb) {
  161.     console.log(chalk.yellow('\n☞  Building development version v' + pkg.version));
  162.  
  163.     sequence(
  164.         'clean:build',
  165.         [
  166.             'compile:html',
  167.             'compile:js'
  168.         ],
  169.         'watch',
  170.         function () {
  171.             console.log(chalk.green('✔  Build complete v' + pkg.version));
  172.             cb(null);
  173.         });
  174. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement