mirror of
https://github.com/Lissy93/twitter-sentiment-visualisation.git
synced 2021-05-12 19:52:18 +03:00
Improved the logic flow of the gulp process for speed
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
* My super amazing gulp setup, does EVERYTHING cool
|
||||
* possible to do to turns already awesome code into
|
||||
* even more awesomely efficient code
|
||||
* View very commented version at https://goo.gl/3K2sFb
|
||||
*
|
||||
* The Gulp tasks are divided into the files in the './tasks/' directory
|
||||
* Read the build documentation at './docs/building.md'
|
||||
*/
|
||||
|
||||
// Include gulp and require directory module
|
||||
@@ -13,4 +15,4 @@ var reqdir = require('require-dir');
|
||||
|
||||
reqdir('./tasks'); // Include the folders containing ALL gulp tasks
|
||||
|
||||
gulp.task('default', ['clean', 'browser-sync']); // Default task
|
||||
gulp.task('default', ['start']); // Default task
|
||||
@@ -1,7 +0,0 @@
|
||||
express = require('express')
|
||||
router = express.Router()
|
||||
router.get '/', (req, res, next) ->
|
||||
res.render 'page_about',
|
||||
title: 'About'
|
||||
pageNum: 5
|
||||
module.exports = router
|
||||
@@ -1,9 +1,16 @@
|
||||
/* Include the necessary modules */
|
||||
var gulp = require('gulp');
|
||||
var bSync = require('browser-sync');
|
||||
var CONFIG = require('../tasks/config').CONFIG;
|
||||
var runSequence = require('run-sequence');
|
||||
|
||||
gulp.task('browser-sync', ['nodemon', 'browserify', 'scripts', 'styles', 'test'], function () {
|
||||
var CONFIG = require('../tasks/config').CONFIG;
|
||||
//todo build before nodemon
|
||||
|
||||
gulp.task('start', function () {
|
||||
runSequence('build', 'test', 'nodemon', 'browser-sync');
|
||||
});
|
||||
|
||||
gulp.task('browser-sync', function () {
|
||||
bSync.init({
|
||||
files: [CONFIG.SOURCE_ROOT+'/**/*.*'],
|
||||
proxy: 'http://localhost:3000',
|
||||
@@ -11,13 +18,20 @@ gulp.task('browser-sync', ['nodemon', 'browserify', 'scripts', 'styles', 'test']
|
||||
browser: ['google chrome'],
|
||||
open: false // Don't open browser automatically - it's annoying
|
||||
});
|
||||
gulp.watch([
|
||||
CONFIG.SOURCE_ROOT+'/**/*.{js,coffee}',
|
||||
'!'+CONFIG.SOURCE_ROOT+'/**/*-{main,module}.{js,coffee}',
|
||||
'models/src/**/*.{js,coffee}'],
|
||||
['scripts', 'test']);
|
||||
gulp.watch(CONFIG.SOURCE_ROOT+'/**/*-{main,module}.{js,coffee}', ['browserify']);
|
||||
gulp.watch(CONFIG.SOURCE_ROOT+'/**/*.{css,less}', ['styles']);
|
||||
gulp.watch(CONFIG.SOURCE_ROOT+"/**/*.js").on('change', bSync.reload);
|
||||
|
||||
/* For each CoffeeScript directory, watch, compile and reload */
|
||||
CONFIG.SCRIPT_PATHS.forEach(function(path) {
|
||||
gulp.watch(path.src, ['scripts']).on('change', bSync.reload);
|
||||
});
|
||||
|
||||
/* Watch build and re-bundle browserify files */
|
||||
gulp.watch(CONFIG.SOURCE_ROOT+'/**/*-{main,module}.{js,coffee}', ['browserify'])
|
||||
.on('change', bSync.reload);
|
||||
|
||||
/* Watch compile and reload LESS, SASS and CSS */
|
||||
gulp.watch(CONFIG.SOURCE_ROOT+'/**/*.{css,less}', ['styles']).on('change', bSync.reload);
|
||||
|
||||
/* And reload browsers when the views change too */
|
||||
gulp.watch("views/**/*.jade").on('change', bSync.reload);
|
||||
|
||||
});
|
||||
@@ -5,12 +5,9 @@ var scriptPaths = require('../tasks/config').CONFIG.SCRIPT_PATHS;
|
||||
|
||||
/* Delete built files */
|
||||
gulp.task('clean', function (cb) {
|
||||
|
||||
var paths = ['public/'];
|
||||
|
||||
scriptPaths.map(function(sp){
|
||||
paths.push(sp.dest+'/*.js');
|
||||
});
|
||||
|
||||
del(paths, cb);
|
||||
});
|
||||
@@ -3,8 +3,18 @@ var gulp = require('gulp');
|
||||
var CONFIG = require('../tasks/config').CONFIG;
|
||||
|
||||
|
||||
/* Configure files to watch for changes - NOT USED AS BY DEFAULT */
|
||||
/* Configure files to watch for changes - NOT USED BY DEFAULT TASK */
|
||||
gulp.task('watch', function() {
|
||||
gulp.watch(CONFIG.SOURCE_ROOT+'/**/*.{js,coffee}', ['scripts', 'browserify']);
|
||||
|
||||
/* For each CoffeeScript directory, watch, compile and reload */
|
||||
CONFIG.SCRIPT_PATHS.forEach(function(path) {
|
||||
gulp.watch(path.src, ['scripts']);
|
||||
});
|
||||
|
||||
/* Watch build and re-bundle browserify files */
|
||||
gulp.watch(CONFIG.SOURCE_ROOT+'/**/*-{main,module}.{js,coffee}', ['browserify']);
|
||||
|
||||
/* Watch compile and reload LESS, SASS and CSS */
|
||||
gulp.watch(CONFIG.SOURCE_ROOT+'/**/*.{css,less}', ['styles']);
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user