Skip to content

Instantly share code, notes, and snippets.

@pmcalabrese
Created January 18, 2015 13:52
Show Gist options
  • Save pmcalabrese/760aa0f8fcf65fcd0c7a to your computer and use it in GitHub Desktop.
Save pmcalabrese/760aa0f8fcf65fcd0c7a to your computer and use it in GitHub Desktop.
gulpfile used for copenhagenjs presentation. Based on the angular-seed example repository
// include gulp
var gulp = require('gulp');
// include plug-ins
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var argv = require('yargs').argv;
var gulpif = require('gulp-if');
var logwarn = require('gulp-logwarn');
var psi = require('psi');
var jsLibsFiles = [
"app/bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js",
"app/bower_components/angular/angular.js",
"app/bower_components/angular-route/angular-route.js"
];
var jsAppFiles = [
"app/app.js",
"app/view1/view1.js",
"app/view2/view2.js",
"app/components/version/version.js",
"app/components/version/version-directive.js",
"app/components/version/interpolate-filter.js"
];
var cssFiles = [
"app/bower_components/html5-boilerplate/css/normalize.css",
"app/bower_components/html5-boilerplate/css/main.css",
"app/app.css"
];
var partialsFiles = [
"app/view*/*.html"
];
var index = [
"app/index_dist.html",
];
gulp.task('default',['libs','app','css','partials','index']);
gulp.task('libs', function() {
gulp.src(jsLibsFiles)
.pipe(concat('libs.js'))
.pipe(gulpif(argv.production, uglify()))
.pipe(gulp.dest('./dist/js/'));
});
gulp.task('app', function() {
gulp.src(jsAppFiles)
.pipe(logwarn())
.pipe(concat('app.js'))
.pipe(gulpif(argv.production, uglify()))
.pipe(gulp.dest('./dist/js/'));
});
gulp.task('css', function() {
gulp.src(cssFiles)
.pipe(concat('all.css'))
.pipe(gulpif(argv.production, minifyCSS()))
.pipe(gulp.dest('./dist/css/'));
});
gulp.task('partials', function() {
gulp.src(partialsFiles)
.pipe(gulp.dest('./dist/'));
});
gulp.task('index', function() {
gulp.src(index)
.pipe(concat("index.html"))
.pipe(gulp.dest('./dist/'));
});
gulp.task('psi',function(cb) {
var options = {
strategy:"desktop"
};
psi.output('https://www.comparo.dk/rejseforsikring',options, function (err) {
if (err) {
console.log('ERROR:',err);
return;
}
console.log('done');
},cb);
});
// Reload only when development files has changed
gulp.task('watch', ['default'], function () {
gulp.watch(jsLibsFiles, ['libs']);
gulp.watch(jsAppFiles, ['app']);
gulp.watch(cssFiles, ['css']);
gulp.watch(partialsFiles, ['partials']);
gulp.watch(index, ['index']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment