-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathsass.js
53 lines (52 loc) · 1.93 KB
/
sass.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const autoprefixer = require('autoprefixer');
const cleanCSS = require('gulp-clean-css');
const concat = require('gulp-concat-util');
const gulpif = require('gulp-if');
const gutil = require('gulp-util');
const postcss = require('gulp-postcss');
const sass = require('gulp-sass')(require('sass'));
const sourcemaps = require('gulp-sourcemaps');
const styleLint = require('gulp-stylelint');
module.exports = function (gulp, opts) {
return function () {
return gulp.src(opts.PROJECT_PATTERNS.sass)
.pipe(styleLint({
reporters: [{
formatter: (opts.argv.debug) ? 'verbose' : 'string',
console: true,
}],
}))
.on('error', function () {
this.emit('end');
})
.pipe(gulpif(opts.argv.debug, sourcemaps.init()))
.pipe(sass())
.on('error', function (error) {
gutil.log(gutil.colors.red(
'Error (' + error.plugin + '): ' + error.messageFormatted)
);
// in dev mode - just continue
this.emit('end');
})
.pipe(
postcss([
autoprefixer({
// browsers are coming from browserslist file
cascade: false,
}),
])
)
.pipe(gulpif(!opts.argv.debug, cleanCSS({
rebase: false,
})))
// this information is added on top of the generated .css file
.pipe(concat.header(
'/*\n This file is generated.\n' +
' Do not edit directly.\n' +
' Edit original files in\n' +
' /private/sass instead\n */ \n\n'
))
.pipe(gulpif(opts.argv.debug, sourcemaps.write()))
.pipe(gulp.dest(opts.PROJECT_PATH.css));
};
};