Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- var concat = require('gulp-concat'),
- del = require('del'),
- uglify = require('gulp-uglify'),
- gulp = require('gulp'),
- browserSync = require('browser-sync'),
- nodemon = require('gulp-nodemon');
- var BROWSER_SYNC_RELOAD_DELAY = 500;
- var paths = {
- js: [
- 'website/app/**/*.js',
- 'website/app/*.js'
- ],
- css: 'website/**/*.css',
- buildDestDel: 'website/_build/*',
- buildDest: 'website/_build',
- concatJsName: 'spawn.scripts.js'
- }
- gulp.task('nodemon', function (cb) {
- var called = false;
- return nodemon({
- script: 'service/service.js',
- watch: ['service/**/*.js'],
- ext: 'js json'
- })
- .on('start', function onStart() {
- if (!called) { cb(); }
- called = true;
- })
- .on('restart', function onRestart() {
- setTimeout(function reload() {
- browserSync.reload({
- stream: false
- });
- }, BROWSER_SYNC_RELOAD_DELAY);
- });
- });
- gulp.task('browser-sync', ['nodemon'], function () {
- browserSync({
- server: {
- baseDir: 'website'
- },
- notify: true,
- open: false
- });
- });
- gulp.task('clean:js', function() {
- return del(paths.buildDestDel);
- });
- gulp.task('js', ['clean:js'], function () {
- return gulp.src(paths.js)
- .pipe(concat(paths.concatJsName))
- .pipe(gulp.dest(paths.buildDest));
- });
- gulp.task('css', function () {
- return gulp.src(paths.css)
- .pipe(browserSync.reload({ stream: true }));
- });
- gulp.task('bs-reload', function () {
- browserSync.reload();
- });
- gulp.task('default', ['browser-sync', 'js'], function () {
- gulp.watch('website/**/*.js', ['js', 'bs-reload']);
- gulp.watch('website/**/*.css', ['css']);
- gulp.watch('website/**/*.html', ['bs-reload']);
- gulp.watch('website/templates/**/*.html', ['bs-reload']);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement