Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generic gulpfile for CakePHP apps. Compiles and minifies sass. Minifies and lints javascript. Generates documentation with yuidoc
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
var yuidoc = require("gulp-yuidoc");
// var chmod = require('gulp-chmod');
// var notify = require("gulp-notify");
// Lint Task
gulp.task('lint', function() {
return gulp.src('./src/scripts/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Compile Our Sass
gulp.task('sass', function() {
return gulp.src('./src/scss/*.scss')
.pipe(sass())
.pipe(minifyCSS({
processImport: false
}))
.pipe(rename({
suffix: ".min"
}))
.pipe(gulp.dest('./app/webroot/css'));
});
gulp.task('docs', function() {
return gulp.src(["./src/scripts/*.js", "./app/Controller/*.php", "./app/Model/*.php"])
.pipe(yuidoc())
.pipe(gulp.dest("./docs"));
});
// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src('./src/scripts/*.js')
.pipe(rename({
suffix: ".min"
}))
.pipe(uglify())
.pipe(gulp.dest('./app/webroot/js'));
});
/*
gulp.task('permissions', function () {
gulp.src('./app/tmp')
.pipe(chmod(755));
.pipe(gulp.dest('./app/tmp'));
});
*/
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('./src/scripts/*.js', ['lint', 'scripts']);
gulp.watch('./src/scss/*.scss', ['sass']);
});
// Default Task
gulp.task('default', ['sass', 'scripts', 'watch', 'docs']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment