Skip to content

Instantly share code, notes, and snippets.

@nodesocket
Last active January 11, 2025 10:49

Revisions

  1. nodesocket revised this gist Aug 2, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ Runs the `serve` and `watch` tasks. Usually this is the only task you will need

    ## Notifications

    Popup task notifications *(similar to growl)* are provided by `gulp-notify`. On error notifications *(either failed to compile less or JavaScript)* also play a frog sound on OS X.g
    Popup task notifications *(similar to growl)* are provided by `gulp-notify`. On error notifications *(either failed to compile less or JavaScript)* also play a frog sound on OS X.

    ## Help

  2. nodesocket revised this gist Aug 1, 2014. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## The perfect Gulp.js file
    ## The perfect gulp.js file

    ## Tasks

    2 changes: 1 addition & 1 deletion package.json
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    {
    "name": "perfect-gulp",
    "description": "The perfect Gulp.js file",
    "description": "The perfect gulp.js file",
    "author": "Commando.io",
    "contributors": [
    {
  3. nodesocket revised this gist Aug 1, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    {
    "name": "",
    "description": "",
    "author": "",
    "name": "perfect-gulp",
    "description": "The perfect Gulp.js file",
    "author": "Commando.io",
    "contributors": [
    {
    "name": "Commando.io",
  4. nodesocket revised this gist Aug 1, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## The perfect Gulp.js
    ## The perfect Gulp.js file

    ## Tasks

  5. nodesocket revised this gist Aug 1, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ Automatically runs `uglify-js` and `less` when relivant files are **created**, *

    Runs the `serve` and `watch` tasks. Usually this is the only task you will need to run.

    ## Growl like notifications
    ## Notifications

    Popup task notifications *(similar to growl)* are provided by `gulp-notify`. On error notifications *(either failed to compile less or JavaScript)* also play a frog sound on OS X.g

  6. nodesocket revised this gist Aug 1, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ Automatically runs `uglify-js` and `less` when relivant files are **created**, *

    Runs the `serve` and `watch` tasks. Usually this is the only task you will need to run.

    ## Notifications
    ## Growl like notifications

    Popup task notifications *(similar to growl)* are provided by `gulp-notify`. On error notifications *(either failed to compile less or JavaScript)* also play a frog sound on OS X.g

  7. nodesocket revised this gist Aug 1, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,7 @@ gulp.task('uglify-js', 'Concat, Ng-Annotate, Uglify JavaScript into a single app
    gulp.src(['client/js/libraries/**/*.js', 'client/js/source/**/*.js'])
    .pipe(concat('app'))
    .pipe(ngAnnotate())
    .on('error', notify.onError("Error: <%= error.message %>"))
    .pipe(uglify())
    .on('error', notify.onError("Error: <%= error.message %>"))
    .pipe(rename({
  8. nodesocket revised this gist Jul 31, 2014. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,10 @@ Automatically runs `uglify-js` and `less` when relivant files are **created**, *

    Runs the `serve` and `watch` tasks. Usually this is the only task you will need to run.

    ## Notifications

    Popup task notifications *(similar to growl)* are provided by `gulp-notify`. On error notifications *(either failed to compile less or JavaScript)* also play a frog sound on OS X.g

    ## Help

    `gulp help` for help.
  9. nodesocket revised this gist Jul 31, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -26,4 +26,4 @@ Runs the `serve` and `watch` tasks. Usually this is the only task you will need

    `gulp help` for help.

    [Screenshot](http://i.imgur.com/YRClqt3.png)
    ![Screenshot](http://i.imgur.com/YRClqt3.png)
  10. nodesocket revised this gist Jul 31, 2014. 3 changed files with 57 additions and 1 deletion.
    29 changes: 29 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    ## The perfect Gulp.js

    ## Tasks

    #### serve

    Runs a **connect** web server, serving files from `/client` on port `3000`.

    #### uglify-js

    Concatenates JavaScript files, runs them through ngAnnotate *(magic angular.js dependency injection)*, uglifies, and names the output file `app.min.js`.

    #### less

    Compiles **less** styles into a single `app.css`.

    #### watch

    Automatically runs `uglify-js` and `less` when relivant files are **created**, **deleted**, or **modified**. Also supports **live reloading** via a [Chrome Extension](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?hl=en).

    #### default

    Runs the `serve` and `watch` tasks. Usually this is the only task you will need to run.

    ## Help

    `gulp help` for help.

    [Screenshot](http://i.imgur.com/YRClqt3.png)
    2 changes: 1 addition & 1 deletion gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ var gulp = require('gulp'),
    });

    gulp.task('serve', 'A simple web server.', serve({
    root: ['client', 'client/views'],
    root: ['client'],
    port: 3000
    }));

    27 changes: 27 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    {
    "name": "",
    "description": "",
    "author": "",
    "contributors": [
    {
    "name": "Commando.io",
    "email": "[email protected]"
    }
    ],
    "version": "0.0.1",
    "dependencies": {},
    "devDependencies": {
    "gulp": "^3.8.2",
    "gulp-concat": "^2.2.0",
    "gulp-help": "^0.1.8",
    "gulp-less": "^1.3.1",
    "gulp-livereload": "^2.1.0",
    "gulp-ng-annotate": "^0.2.0",
    "gulp-notify": "^1.4.0",
    "gulp-rename": "^1.2.0",
    "gulp-serve": "^0.2.0",
    "gulp-uglify": "^0.3.1",
    "gulp-watch": "^0.6.8",
    "moment": "^2.7.0"
    }
    }
  11. nodesocket created this gist Jul 31, 2014.
    71 changes: 71 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    var gulp = require('gulp'),
    watch = require('gulp-watch'),
    liveReload = require('gulp-livereload'),
    concat = require('gulp-concat'),
    ngAnnotate = require('gulp-ng-annotate'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename'),
    moment = require('moment'),
    notify = require('gulp-notify');
    less = require('gulp-less');
    serve = require('gulp-serve');

    require('gulp-help')(gulp, {
    description: 'Help listing.'
    });

    gulp.task('serve', 'A simple web server.', serve({
    root: ['client', 'client/views'],
    port: 3000
    }));

    gulp.task('uglify-js', 'Concat, Ng-Annotate, Uglify JavaScript into a single app.min.js.', function() {
    gulp.src(['client/js/libraries/**/*.js', 'client/js/source/**/*.js'])
    .pipe(concat('app'))
    .pipe(ngAnnotate())
    .pipe(uglify())
    .on('error', notify.onError("Error: <%= error.message %>"))
    .pipe(rename({
    extname: ".min.js"
    }))
    .pipe(gulp.dest('client/js'))
    .pipe(notify('Uglified JavaScript (' + moment().format('MMM Do h:mm:ss A') + ')'))
    .pipe(liveReload({
    auto: false
    }));
    });

    gulp.task('less', 'Compile less into a single app.css.', function() {
    gulp.src(['client/styles/bootstrap/bootstrap.less', 'client/styles/*.less'])
    .pipe(concat('app'))
    .pipe(less())
    .on('error', notify.onError("Error: <%= error.message %>"))
    .pipe(gulp.dest('client/styles'))
    .pipe(notify('Compiled less (' + moment().format('MMM Do h:mm:ss A') + ')'))
    .pipe(liveReload({
    auto: false
    }));
    });

    gulp.task('watch', 'Watch for changes and live reloads Chrome. Requires the Chrome extension \'LiveReload\'.', function() {
    liveReload.listen();
    watch({
    glob: 'client/js/source/**/*.js'
    }, function() {
    gulp.start('uglify-js');
    });

    watch({
    glob: 'client/styles/*.less',
    }, function() {
    gulp.start('less');
    });

    watch({
    glob: 'client/views/**/*.html'
    }).pipe(liveReload({
    auto: false
    }));
    });

    gulp.task('default', ['watch', 'serve']);