-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
74 lines (65 loc) · 2.01 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var gulp = require('gulp'),
cssmin = require('gulp-cssmin'),
sass = require('gulp-sass'),
uglify = require('gulp-uglify'),
watchify = require('gulp-watchify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer');
gulp.task('default', ['watch']);
var isDist = false;
gulp.task('enable-dist-mode', function() { isDist = true; });
gulp.task('watch', ['browserify', 'sass'], function() {
gulp.watch('scss/**/*.scss', ['sass']);
});
gulp.task('dist', ['enable-dist-mode', 'browserify', 'sass']);
gulp.task('sass', function () {
var result = gulp.src('scss/*.scss')
.pipe(sourcemaps.init())
.pipe(
sass({
includePaths: [
'./node_modules/breakpoint-sass/stylesheets/'
]
})
.on('error', sass.logError)
)
.pipe(autoprefixer({
browsers: ['> 1%', 'last 3 versions', 'Firefox ESR', 'iOS >= 8']
}))
.pipe(sourcemaps.write('../maps'));
if (isDist) {
result = result.pipe(cssmin());
}
return result.pipe(gulp.dest('./css'));
});
gulp.task('browserify', watchify(function(watchify) {
var result = gulp.src('src/app.js')
.pipe(watchify({watch:!isDist}));
if (isDist) {
result = result.pipe(buffer()).pipe(uglify());
}
return result.pipe(gulp.dest('./js'));
}));
// gulp.task('sass:dev', function () {
// gulp.src('./scss/*.scss')
// .pipe(sourcemaps.init())
// .pipe(
// sass({
// includePaths: [
// './node_modules/breakpoint-sass/stylesheets/'
// ]
// })
// .on('error', sass.logError)
// )
// .pipe(autoprefixer({
// browsers: ['last 2 version']
// }))
// .pipe(sourcemaps.write('../maps'))
// .pipe(gulp.dest('./css'));
// });
// gulp.task('sass:watch', function () {
// gulp.watch('./scss/**/*.scss', ['sass:dev']);
// });
// gulp.task('default', ['sass:dev', 'sass:watch']);