forked from FrontendMatter/corner-ribbon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
49 lines (43 loc) · 1.09 KB
/
gulpfile.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
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var __SRC = './sass/main.scss';
var __DIST = './dist';
var __WATCH = ['./sass/**/*.scss'];
function sass (src, dist, minify) {
return gulp.src(src)
// Compile Sass
.pipe($.sass({
// Resolve Sass file imports from node_modules
importer: require('sass-importer-npm')
})
// Handle errors
.on('error', $.sass.logError))
// Post CSS
.pipe($.postcss([
// autoprefixer
require('autoprefixer')({ browsers: ['last 2 versions'] })
]))
// rename
.pipe($.rename({ basename: "corner-ribbon" }))
// uncompressed
.pipe($.if(minify, gulp.dest(dist)))
// (optional) Minify CSS
.pipe($.if(minify, $.cleanCss()))
// rename
.pipe($.rename({ extname: ".min.css" }))
// Write CSS file
.pipe(gulp.dest(dist))
}
// Build dev
gulp.task('build:dev', function () {
return sass(__SRC, __DIST);
});
// Build production
gulp.task('build', function () {
return sass(__SRC, __DIST, true);
});
// Watch
gulp.task('watch', ['build:dev'], function () {
gulp.watch(__WATCH, ['build:dev']);
});
gulp.task('default', ['build']);