Skip to content

Instantly share code, notes, and snippets.

@boynoiz
Last active February 22, 2016 14:16
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 boynoiz/a2f83bfcdf846a735199 to your computer and use it in GitHub Desktop.
Save boynoiz/a2f83bfcdf846a735199 to your computer and use it in GitHub Desktop.
var gulp = require('gulp');
var sass = require('gulp-sass');
var postcss = require('gulp-postcss');
var cssnano = require('gulp-cssnano');
var sourcemaps = require('gulp-sourcemaps');
var merge = require('merge-stream');
var clone = require('gulp-clone');
var bower_path = 'vendor/bower_components';
var paths = [
'bootstrap' : bower_path + '/bootstrap-sass/assets',
];
gulp.task('front-sass-ex', function()
{
var processors = [
require("postcss-cssnext")({
'browers': ['last 2 version'],
'customProperties': true,
'colorFunction': true,
'customSelectors': true,
'sourcemap': true,
'compress': false
})
];
var css = gulp.src(resource_path + '/sass/app.scss')
.pipe(sourcemaps.init())
.pipe(sass(
{
outputStyle: 'expanded',
sourceMap: true,
sourceMapRoot: [
resource_path + '/sass/app/',
paths.bootstrap + '/stylesheets'
],
includePaths: [
require('node-bourbon').includePaths,
require('node-neat').includePaths,
paths.bootstrap + '/stylesheets'
],
noCache: true,
errLogToConsole: true
}))
.pipe(postcss(processors))
.pipe(gulp.dest('public/assets/css'));
var min = css.pipe(clone())
.pipe(cssnano({discardComments: {removeAll: true}}))
.pipe(rename('app.min.css'));
return merge(css, min)
.pipe(sourcemaps.write('.', {
sourceRoot: resource_path + '/sass/app/',
includeContent: false
}))
.pipe(gulp.dest(''));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment