11'use strict'
22
33const gulp = require ( 'gulp' )
4-
5- const sass = require ( 'gulp-sass' )
6-
4+ const sass = require ( 'gulp-sass' ) ( require ( 'sass' ) )
75const autoprefixer = require ( 'gulp-autoprefixer' )
8-
96const cmq = require ( 'gulp-group-css-media-queries' )
10-
117const csso = require ( 'gulp-csso' )
12-
138const size = require ( 'gulp-size' )
14-
159const gulpif = require ( 'gulp-if' )
16-
1710const handleErrors = require ( '../util/handleErrors' )
18-
1911const browserSync = require ( 'browser-sync' )
2012
21- gulp . task ( 'sass' , function ( ) {
13+ function sassTask ( ) {
2214 const dest = './public/css'
2315
2416 console . log ( 'app sass build' )
2517
2618 gulp . src ( './public/scss/app.{scss,sass}' )
2719 . pipe ( sass ( {
2820 precision : 7 ,
29- outputStyle : 'nested'
30- } ) )
31- . on ( 'error' , handleErrors )
21+ outputStyle : 'expanded'
22+ } ) . on ( 'error' , sass . logError ) )
3223 . pipe ( autoprefixer ( ) )
3324 . pipe ( gulpif ( global . isProduction , cmq ( {
3425 log : true
@@ -38,16 +29,15 @@ gulp.task('sass', function () {
3829 . pipe ( browserSync . reload ( {
3930 stream : true
4031 } ) )
41- . pipe ( size ( ) )
32+ . pipe ( size ( { showFiles : true } ) )
4233
4334 console . log ( 'export sass build' )
4435
4536 return gulp . src ( './public/scss/export.{scss,sass}' )
4637 . pipe ( sass ( {
4738 precision : 7 ,
48- outputStyle : 'nested'
49- } ) )
50- . on ( 'error' , handleErrors )
39+ outputStyle : 'expanded'
40+ } ) . on ( 'error' , sass . logError ) )
5141 . pipe ( autoprefixer ( ) )
5242 . pipe ( gulpif ( global . isProduction , cmq ( {
5343 log : true
@@ -57,5 +47,9 @@ gulp.task('sass', function () {
5747 . pipe ( browserSync . reload ( {
5848 stream : true
5949 } ) )
60- . pipe ( size ( ) )
61- } )
50+ . pipe ( size ( { showFiles : true } ) )
51+ }
52+
53+ gulp . task ( 'sass' , sassTask )
54+
55+ module . exports = sassTask
0 commit comments