Skip to content

Instantly share code, notes, and snippets.

@ahmadawais
Created January 13, 2016 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmadawais/5311fd098827a63a1c67 to your computer and use it in GitHub Desktop.
Save ahmadawais/5311fd098827a63a1c67 to your computer and use it in GitHub Desktop.
Task `styles`
/**
* Task: styles
*
* Compiles Sass, Autoprefixes it and Minifies CSS.
*
* This task does the following:
* 1. Gets the source scss file
* 2. Compiles Sass to CSS
* 3. Writes Sourcemaps for it
* 4. Autoprefixes it and generates style.css
* 5. Renames the CSS file with suffix .min.css
* 6. Minifies the CSS file and generates style.min.css
*/
gulp.task('styles', function () {
gulp.src( styleSRC )
.pipe( sourcemaps.init() )
.pipe( sass( {
errLogToConsole: true,
outputStyle: 'compact',
//outputStyle: 'compressed',
// outputStyle: 'nested',
// outputStyle: 'expanded',
precision: 10
} ) )
.pipe( sourcemaps.write( { includeContent: false } ) )
.pipe( sourcemaps.init( { loadMaps: true } ) )
.pipe( autoprefixer(
'last 2 version',
'> 1%',
'safari 5',
'ie 8',
'ie 9',
'opera 12.1',
'ios 6',
'android 4' ) )
.pipe( sourcemaps.write ( styleDestination ) )
.pipe( gulp.dest( styleDestination ) )
.pipe( rename( { suffix: '.min' } ) )
.pipe( minifycss( {
maxLineLen: 10
}))
.pipe( gulp.dest( styleDestination ) )
.pipe( notify( { message: 'TASK: "styles" Completed!', onLast: true } ) )
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment