Skip to content

Instantly share code, notes, and snippets.

@colindecarlo
Created May 8, 2014 02:18
Show Gist options
  • Save colindecarlo/e87317fb5ea92a428be9 to your computer and use it in GitHub Desktop.
Save colindecarlo/e87317fb5ea92a428be9 to your computer and use it in GitHub Desktop.
var gulp = require('gulp');
var less = require('gulp-less');
var _ = require('underscore');
var paths = {
sources: {
less: 'app/assets/less/**/*.less'
},
dests: {
js: 'public/js',
css: 'public/css',
fonts: 'public/fonts'
}
};
var vendors = {
bootstrap: {
path: 'public/bower_components/bootstrap/dist',
sourceDirs: {
js: ['bootstrap.js'],
css: ['bootstrap.css'],
fonts: [
'glyphicons-halflings-regular.eot',
'glyphicons-halflings-regular.svg',
'glyphicons-halflings-regular.ttf',
'glyphicons-halflings-regular.woff'
]
}
},
jquery: {
path: 'public/bower_components/jquery/dist',
sources: ['jquery.js'],
dest: paths.dests.js,
}
};
// build out the projects own .less source
gulp.task('less', function() {
gulp.src(paths.sources.less)
.pipe(less())
.pipe(gulp.dest(paths.dests.css));
});
gulp.task('vendor-assets', function() {
var move = function (source, dest) {
console.log('moving ' + source + ' to ' + dest);
gulp.src(source).pipe(gulp.dest(dest));
},
processVendor = function(config) {
if (config.sources) {
processVendorSources(config.path, config.sources, config.dest);
} else if (config.sourceDirs) {
_.each(config.sourceDirs, processVendorDirectories(config.path));
} else {
throw new Error("Fuck");
}
},
processVendorSources = function (basePath, sources, destination) {
for (var i = 0; i < sources.length; i++) {
var source = basePath + '/' + sources[i];
move(source, destination);
}
},
processVendorDirectories = function (basePath) {
return function (sources, sourceType) {
var path = basePath + '/' + sourceType,
destination = paths.dests[sourceType];
processVendorSources(path, sources, destination);
};
};
_.each(vendors, processVendor);
});
gulp.task('watch', function() {
gulp.watch(paths.sources.less, ['less']);
});
gulp.task('default', function() {
console.log("hello world!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment