This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run these commands in a terminal window (note - DON'T replace the whoami part...thats a linux command to get your user! | |
sudo chown -R `whoami` ~/.npm | |
sudo chown -R `whoami` /usr/local/lib/node_modules | |
# ...and...if you're on a mac (like I am), and still see errors after running these commands, then run this last one and you should be good. (Recommend you try testing before you do this one. I don't like changing the permissions on the ENTIRE /usr/local directory unless it really seems necessary!) | |
sudo chown -R `whoami` /usr/local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Delete files and folders | |
* You might want delete some files before running your build. Since deleting files doesn't work on the file contents there's no reason to use a gulp plugin. An excellent opportunity to use a vanilla node module. | |
* | |
* Let's use the del module for this example as it supports multiple files and globbing: | |
*/ | |
// $ npm install --save-dev gulp del | |
// Imagine this file structure: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Combining streams to handle errors | |
// By default, emitting an error on a stream will cause it to be thrown unless it already has a listener attached to the error event. This gets a bit tricky when you're working with longer pipelines of streams. | |
// By using multistream you can turn a series of streams into a single stream, meaning you only need to listen to the error event in one place in your code. | |
// Here's an example of using it in a gulpfile: | |
var Multistream = require('multistream'); | |
var uglify = require('gulp-uglify'); | |
var gulp = require('gulp'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Files are passed through the whole pipe chain on every run by default. By using gulp-changed only changed files will be passed through. This can speed up consecutive runs considerably. | |
// npm install --save-dev gulp gulp-changed gulp-jscs gulp-uglify | |
var gulp = require('gulp'); | |
var changed = require('gulp-changed'); | |
var jscs = require('gulp-jscs'); | |
var uglify = require('gulp-uglify'); | |
// we define some constants here so they can be reused |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install --save-dev gulp gulp-if gulp-uglify minimist | |
var gulp = require('gulp'); | |
var gulpif = require('gulp-if'); | |
var uglify = require('gulp-uglify'); | |
var minimist = require('minimist'); | |
var knownOptions = { | |
string: 'env', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// With gulp-watch: | |
var gulp = require('gulp'); | |
var sass = require('gulp-sass'); | |
var watch = require('gulp-watch'); | |
gulp.task('default', function() { | |
return gulp.src('sass/*.scss') | |
.pipe(watch()) | |
.pipe(sass()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
If you have a set of folders, and wish to perform a set of tasks on each, for instance... | |
/scripts | |
/scripts/jquery/*.js | |
/scripts/angularjs/*.js | |
...and want to end up with... | |
/scripts | |
/scripts/jquery.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
By default, tasks run with maximum concurrency -- e.g. it launches all the tasks at once and waits for nothing. If you want to create a series where tasks run in a particular order, you need to do two things: | |
give it a hint to tell it when the task is done, | |
and give it a hint that a task depends on completion of another. | |
For these examples, let's presume you have two tasks, "one" and "two" that you specifically want to run in this order: | |
In task "one" you add a hint to tell it when the task is done. Either take in a callback and call it when you're done or return a promise or stream that the engine should wait to resolve or end respectively. | |
In task "two" you add a hint telling the engine that it depends on completion of the first task. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"desktop" : { | |
"src" : [ | |
"dev/desktop/js/**/*.js", | |
"!dev/desktop/js/vendor/**" | |
], | |
"dest" : "build/desktop/js" | |
}, | |
"mobile" : { | |
"src" : [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install --save-dev gulp merge-stream | |
var gulp = require('gulp'); | |
var merge = require('merge-stream'); | |
gulp.task('test', function() { | |
var bootstrap = gulp.src('bootstrap/js/*.js') | |
.pipe(gulp.dest('public/bootstrap')); | |
var jquery = gulp.src('jquery.cookie/jquery.cookie.js') |
OlderNewer