Skip to content

Instantly share code, notes, and snippets.

@tomasdev
Created February 4, 2014 19:22
Show Gist options
  • Save tomasdev/8810449 to your computer and use it in GitHub Desktop.
Save tomasdev/8810449 to your computer and use it in GitHub Desktop.
Gulp FTW.
{
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"forin": true,
"immed": true,
"indent": 4,
"latedef": true,
"maxparams": 3,
"newcap": true,
"noarg": true,
"noempty": true,
"nonew": true,
"quotmark": "single",
"strict": true,
"undef": true,
"unused": true,
"trailing": true,
"browser": true,
"jquery": true,
"white": true,
"globals": {
"console": false,
"Error": false
}
}
var gulp = require('gulp'),
gutil = require('gulp-util'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
jshint = require('gulp-jshint'),
mocha = require('gulp-mocha'),
paths = {
src: {
root: 'src/',
html: 'src/**/*.html',
js: [
'src/app.js',
'src/components/**/*.js'
],
css: 'src/components/**/sass/*.scss',
},
dest: {
root: 'dist/',
css: 'dist/components/'
}
};
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['jshint', 'copy', 'sass']);
// Rerun the task when a file changes
gulp.task('watch', function () {
gulp.watch(paths.src.html, ['copy']);
gulp.watch(paths.src.js, ['jshint', 'copy']);
gulp.watch(paths.src.css, ['sass']);
});
// Validate all JS files not in /lib/
gulp.task('jshint', function () {
return gulp.src(paths.src.js)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'));
});
// Compile all components .scss into the corresponding .css
gulp.task('sass', function () {
return gulp.src(paths.src.css)
.pipe(sass())
.pipe(rename(function (dir, base, ext) {
return '../css/' + base + ext;
}))
.pipe(gulp.dest(paths.dest.css));
});
// Copy all components static assets, JS + HTML
gulp.task('copy', function () {
// HTML
gulp.src(paths.src.html)
.pipe(gulp.dest(paths.dest.root));
// JS
gulp.src(paths.src.root + '**/*.js', { base: paths.src.root })
.pipe(gulp.dest(paths.dest.root));
});
// Test Driven Development, call me maybe
gulp.task('test', function () {
// TODO: this thingy.
// @see https://npmjs.org/package/gulp-mocha/
// gulp.src('Frontend/test/specs/test.js')
// .pipe(mocha({reporter: 'nyan'}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment