Skip to content

Instantly share code, notes, and snippets.

@andreasnymark
Created October 2, 2014 07:07
Show Gist options
  • Save andreasnymark/c4773831f32ed19a18d1 to your computer and use it in GitHub Desktop.
Save andreasnymark/c4773831f32ed19a18d1 to your computer and use it in GitHub Desktop.
gulpfile.js for KSS
var gulp = require( 'gulp' ),
less = require( 'gulp-less' ),
prefix = require( 'gulp-autoprefixer' ),
minify = require( 'gulp-minify-css' ),
base64 = require( 'gulp-base64' ),
media = require( 'gulp-combine-media-queries' ),
size = require( 'gulp-size' ),
kss = require( 'gulp-kss' );
var sources = {
less: {
main : 'assets/styles/dev/main.less',
all : 'assets/styles/dev/**/*.less'
}
};
var targets = {
css: 'assets/styles/prod/'
};
gulp.task( 'compile-kss', function() {
return gulp.src( sources.less.all )
.pipe( kss( {
overview : __dirname + '/Styleguide/styleguide.md',
templateDirectory : __dirname + '/Styleguide/template'
} ) )
.pipe( gulp.dest( 'Styleguide/public' ) );
});
gulp.task( 'compile-less', function() {
return gulp.src( sources.less.main )
.pipe( less() )
.pipe( prefix( 'last 2 versions' ) )
.pipe( base64() )
.pipe( media( { log : true } ) )
.pipe( minify() )
.pipe( size() )
.pipe( gulp.dest( targets.css ) );
});
gulp.task( 'watch', function() {
gulp.watch( sources.less.all, [ 'compile-less' ] );
gulp.watch( 'assets/styles/prod/main.css', [ 'compile-kss' ] );
});
gulp.task( 'default', [ 'compile-less', 'compile-kss', 'watch' ] );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment