Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- /* ------------------------------------------------------------------------ *\
- REQUIREMENTS
- \* ------------------------------------------------------------------------ */
- var
- _ = require('lodash'),
- chalk = require('chalk'),
- sequence = require('run-sequence'),
- del = require('del');
- ////////////////////////////////////////////////////////////////////////////////
- var
- gulp = require('gulp'),
- plugins = require('gulp-load-plugins')(),
- server = require('./server');
- /* ------------------------------------------------------------------------ *\
- VARIABLES
- \* ------------------------------------------------------------------------ */
- var
- pkg = require('./package.json'),
- cwd = process.cwd(),
- config = null;
- /* ------------------------------------------------------------------------ *\
- HTML
- \* ------------------------------------------------------------------------ */
- gulp.task('compile:html', function (cb) {
- gulp.src(['client/views/**/*.html'])
- .pipe(gulp.dest('build/views'));
- gulp.src(['client/*.html'])
- .pipe(gulp.dest('build/'));
- cb(null);
- });
- /* ------------------------------------------------------------------------ *\
- JS
- \* ------------------------------------------------------------------------ */
- gulp.task('compile:js', function (cb) {
- return gulp.src([
- 'bower_components/jquery/dist/jquery.js',
- 'bower_components/lodash/dist/lodash.compat.js',
- 'bower_components/angular/angular.js',
- 'bower_components/angular-ui-router/release/angular-ui-router.js',
- 'bower_components/angular-translate/angular-translate.js',
- 'bower_components/angular-mailchimp/angular-mailchimp.js',
- 'client/js/app.js',
- 'client/js/config/*.js',
- 'client/js/controllers/*.js',
- 'client/js/directives/*.js',
- 'client/js/helpers/*.js',
- 'client/js/services/*.js'
- ])
- .pipe(plugins.plumber())
- .pipe(plugins.concat('app.min.js'))
- .pipe(plugins.uglify())
- .pipe(gulp.dest('build/js'))
- .pipe(plugins.filesize());
- });
- /* ------------------------------------------------------------------------ *\
- SERVER
- \* ------------------------------------------------------------------------ */
- gulp.task('serve', function (cb) {
- plugins.nodemon({ script: 'server.js', ext: 'json js', ignore: ['client/*', 'build/*'] })
- .on('restart', function () {
- console.log(chalk.green('✔ Restarted server'));
- });
- cb(null);
- });
- /* ------------------------------------------------------------------------ *\
- WATCH
- \* ------------------------------------------------------------------------ */
- gulp.task('watch', ['serve'], function (cb) {
- plugins.livereload.listen();
- gulp.watch(['client/**/*.html'], ['compile:html']);
- gulp.watch(['client/**/*.js'], ['compile:js']);
- gulp.watch('client/**')
- .on('change', plugins.livereload.changed);
- cb(null);
- });
- /* ------------------------------------------------------------------------ *\
- CLEAN
- \* ------------------------------------------------------------------------ */
- gulp.task('clean:build', function (cb) {
- del(['build'], cb);
- });
- /* ------------------------------------------------------------------------ *\
- DEFAULT
- \* ------------------------------------------------------------------------ */
- gulp.task('default', function (cb) {
- console.log(chalk.yellow('----------------------------------------------'));
- console.log(chalk.yellow('project: ' + pkg.name));
- console.log(chalk.yellow('version: ' + pkg.version));
- console.log(chalk.yellow('----------------------------------------------'));
- gulp.start('dev');
- });
- /* ------------------------------------------------------------------------ *\
- DEVELOPMENT
- \* ------------------------------------------------------------------------ */
- gulp.task('dev', function (cb) {
- console.log(chalk.yellow('\n☞ Building development version v' + pkg.version));
- sequence(
- 'clean:build',
- [
- 'compile:html',
- 'compile:js'
- ],
- 'watch',
- function () {
- console.log(chalk.green('✔ Build complete v' + pkg.version));
- cb(null);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement