Created
November 2, 2014 11:08
-
-
Save dariocravero/46a2339ab366cb577dcd to your computer and use it in GitHub Desktop.
gulpfile.js and public/bower.json
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
{ | |
"name": "my-app", | |
"version": "0.0.1", | |
"dependencies": { | |
"normalize-css": "latest", | |
"angular": "latest" | |
} | |
} |
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
#!/usr/bin/env gulp | |
var argv = require('optimist') | |
.usage("Usage: $0 --version [The version you're compiling to]") | |
.demand(['version']) | |
.argv, | |
fs = require('fs'), | |
gulp = require('gulp'), | |
concat = require('gulp-concat') | |
cloudfiles = require("gulp-cloudfiles"), | |
csslint = require('gulp-csslint'), | |
gutil = require('gulp-util'), | |
jshint = require('gulp-jshint'), | |
minifyCss = require('gulp-minify-css'), | |
// rsync = require('gulp-rsync'), | |
scsslint = require('gulp-scss-lint'), | |
uglifyJs = require('gulp-uglifyjs'), | |
rackspace = JSON.parse(fs.readFileSync('./config/rackspace.json')), | |
App = { | |
tmp: './tmp', | |
dist: './public/dist/' + argv.version, | |
src: { | |
css: [ | |
'./public/bower_components/normalize-css/normalize.css', | |
'./public/stylesheets/application.css' | |
], | |
js: { | |
vendor: [ | |
'./public/bower_components/angular/angular.js', | |
'./public/javascripts/some-utils-that-dont-change-much.js' | |
], | |
app: [ | |
'./public/javascripts/app.js', | |
'./public/javascripts/app/something.js' | |
] | |
} | |
}, | |
cdn: { | |
dst: argv.version + '/' //, | |
// host: 'rsync.keycdn.com', | |
// user: 'your-user' | |
} | |
}; | |
// Explicity define the files to sync to the CDN over rsync | |
// App.cdn.src = [ | |
// App.dist + '/app.js', | |
// App.dist + '/app.css', | |
// App.dist + '/vendor.js' | |
// ]; | |
gulp.task('csslint', function() { | |
gulp | |
.src(App.src.css) | |
.pipe(csslint()) | |
.pipe(csslint.reporter()); | |
}); | |
gulp.task('scsslint', function() { | |
gulp | |
.src('./app/stylesheets/**/*.scss') | |
.pipe(scsslint()); | |
}); | |
gulp.task('jshint', function() { | |
gulp | |
.src(App.src.js.app) | |
.pipe(jshint()) | |
.pipe(jshint.reporter()); | |
gulp | |
.src(App.dist + '*.js') | |
.pipe(jshint()) | |
.pipe(jshint.reporter()); | |
}); | |
gulp.task('css', function() { | |
var stream = gulp | |
.src(App.src.css) | |
.pipe(concat('app.css')) | |
.pipe(minifyCss()) | |
.pipe(gulp.dest(App.dist)); | |
return stream; | |
}); | |
gulp.task('js', function() { | |
var stream = gulp | |
.src(App.src.js.app) | |
.pipe(uglifyJs('app.js', {mangle: false})) | |
.pipe(gulp.dest(App.dist)); | |
return stream; | |
}); | |
gulp.task('vendor', function() { | |
var stream = gulp | |
.src(App.src.js.vendor) | |
.pipe(uglifyJs('vendor.js')) | |
.pipe(gulp.dest(App.dist)); | |
return stream; | |
}); | |
gulp.task('assets', ['css', 'js', 'vendor'], function() { | |
gutil.log(' v' + argv.version); | |
gulp | |
.src(App.cdn.src, {read: false}) | |
.pipe(cloudfiles(rackspace, { | |
uploadPath: App.cdn.dst | |
})); | |
// .pipe(rsync({ | |
// root: App.dist, | |
// username: App.cdn.user, | |
// hostname: App.cdn.host, | |
// destination: App.cdn.dst, | |
// ssh: true, | |
// progress: true | |
// })); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment