Created
July 20, 2015 08:16
-
-
Save johannessteu/21943a111b92131224d3 to your computer and use it in GitHub Desktop.
Gulp Tasks for Neos
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
var gulp = require('gulp'); | |
// Plugins | |
var sass = require('gulp-sass'); | |
var uglify = require('gulp-uglify'); | |
var cssmin = require('gulp-cssmin'); | |
var rename = require('gulp-rename'); | |
var imagemin = require('gulp-imagemin'); | |
var concat = require('gulp-concat'); | |
var copy = require('gulp-copy'); | |
var print = require('gulp-print'); | |
var runSequence = require('run-sequence'); | |
var pngquant = require('imagemin-pngquant'); | |
// Paths | |
var packagePath = '../'; | |
var stylesPath = packagePath + 'Resources/Private/Styles'; | |
var destPath = packagePath + 'Resources/Public/Styles'; | |
var libraryPath = packagePath + "Resources/Private/Library"; | |
// Tasks | |
gulp.task('sass', function (cb) { | |
return gulp.src(stylesPath + '/*.scss') | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(gulp.dest(destPath)); | |
}); | |
gulp.task('minify-css', function () { | |
gulp.src(destPath + '/style.css') | |
.pipe(cssmin()) | |
.pipe(rename({suffix: '.min'})) | |
.pipe(gulp.dest(destPath)); | |
gulp.src(destPath + '/print.css') | |
.pipe(cssmin()) | |
.pipe(rename({suffix: '.min'})) | |
.pipe(gulp.dest(destPath)); | |
return true; | |
}); | |
gulp.task('imagemin', function () { | |
return gulp.src(packagePath + 'Resources/Private/Images/*') | |
.pipe(imagemin({ | |
progressive: true, | |
svgoPlugins: [{removeViewBox: false}], | |
use: [pngquant()] | |
})) | |
.pipe(gulp.dest(packagePath + 'Resources/Public/Images/')); | |
}); | |
gulp.task("copy-fonts", function() { | |
return gulp.src(packagePath + '../../Libraries/fortawesome/font-awesome/fonts/*') | |
.pipe(gulp.dest(packagePath + 'Resources/Public/fonts')) | |
.pipe(print()); | |
}); | |
gulp.task('concatjs', function() { | |
return gulp.src([ | |
libraryPath + 'jQuery.min.1.11.0.js', | |
libraryPath + 'functions.js', | |
packagePath + "../../Application/TYPO3.Neos/Resources/Public/JavaScript/LastVisitedNode.js" | |
]) | |
.pipe(concat('Main.js')) | |
.pipe(gulp.dest(packagePath + "Resources/Public/Scripts/")); | |
}); | |
gulp.task('uglifyjs', function() { | |
return gulp.src(packagePath + "Resources/Public/Scripts/Main.js") | |
.pipe(uglify()) | |
.pipe(rename({suffix: '.min'})) | |
.pipe(gulp.dest(packagePath + "Resources/Public/Scripts/")); | |
}); | |
// Watch Tasks | |
gulp.task('watch-css', function () { | |
gulp.watch(packagePath + '/**/*.scss', ['sass']) | |
gulp.watch(destPath + '/styles.css', ['minify-css']); | |
}); | |
gulp.task('watch-js', function () { | |
gulp.watch(packagePath + 'Resources/Private/Scripts/*.js', ['concatjs']) | |
gulp.watch(packagePath + 'Resources/Public/Scripts/Main.js', ['uglifyjs']) | |
}); | |
gulp.task('watch-images', function () { | |
gulp.watch(packagePath + 'Resources/Private/Images/*', ['imagemin']) | |
}); | |
gulp.task('compile-css', function() { runSequence('sass', 'minify-css'); }); | |
gulp.task('compile-js', function() { runSequence('concatjs', 'uglifyjs') }); | |
gulp.task('compile-images', ['imagemin']); | |
gulp.task('watch', ['watch-css', 'watch-js', 'watch-images']); | |
gulp.task('compile', ['compile-css', 'compile-js', 'compile-images', 'copy-fonts']); |
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
{ | |
"dependencies": { | |
"gulp": "~3", | |
"gulp-sass": "~2", | |
"gulp-uglify": "~1.2", | |
"gulp-sourcemaps": "~1.5", | |
"gulp-cssmin": "~0.1", | |
"gulp-rename": "~1.2", | |
"gulp-concat": "~2.6", | |
"gulp-print": "~1.1", | |
"gulp-copy": "0.0.2", | |
"gulp-imagemin": "~2.3", | |
"imagemin-pngquant": "~4.1", | |
"run-sequence": "~1.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment