Created
February 7, 2017 09:13
-
-
Save dim2k2006/bad384fac542d36206a310032fdd2cd6 to your computer and use it in GitHub Desktop.
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
import gulp from 'gulp'; | |
import gulpif from 'gulp-if'; | |
import plumber from 'gulp-plumber'; | |
import inheritance from 'gulp-sass-inheritance'; | |
import filter from 'gulp-filter'; | |
import sass from 'gulp-sass'; | |
import sassGlob from 'gulp-sass-glob'; | |
import postcss from 'gulp-postcss'; | |
import autoprefixer from 'autoprefixer'; | |
import cmq from 'gulp-combine-mq'; | |
import minifyCss from 'gulp-minify-css'; | |
import rename from 'gulp-rename'; | |
import cached from 'gulp-cached'; | |
import sourcemaps from 'gulp-sourcemaps'; | |
import flatten from 'gulp-flatten'; | |
import errorHandler from '../utils/errorHandler'; | |
import settings from '../settings'; | |
import { browsers } from '../../package.json'; | |
gulp.task('styles', () => { | |
return gulp.src(`${settings.baseSrc}/**/*.scss`) | |
.pipe(sourcemaps.init()) | |
.pipe(plumber({errorHandler: errorHandler})) | |
.pipe(cached('sass')) | |
.pipe(gulpif(global.watch, inheritance({dir: settings.baseSrc}))) | |
// debug | |
.on('data', function(file) { | |
// if (global.watch) { | |
console.log('After inheritance'); | |
console.log(file.path); | |
console.log(file.relative); | |
console.log('-------------------'); | |
// } | |
}) | |
// debug | |
.pipe(filter((file) => /sass\/.*?\/main.scss$/.test(file.path))) | |
// .pipe(sassGlob()) | |
.pipe(sass()) | |
.pipe(postcss([ | |
autoprefixer({ | |
browsers: [ | |
'Android >= ' + browsers.android, | |
'Chrome >= ' + browsers.chrome, | |
'Firefox >= ' + browsers.firefox, | |
'Explorer >= ' + browsers.ie, | |
'iOS >= ' + browsers.ios, | |
'Opera >= ' + browsers.opera, | |
'Safari >= ' + browsers.safari | |
] | |
}) | |
])) | |
.pipe(cmq({beautify: false})) | |
.pipe(minifyCss()) | |
.pipe(flatten({includeParents: -1})) | |
.pipe(rename({ | |
basename: "css/main", | |
suffix: '.min' | |
})) | |
.pipe(sourcemaps.write()) | |
.pipe(gulp.dest(settings.baseDist)) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment