-
Notifications
You must be signed in to change notification settings - Fork 14
/
gulpfile.babel.js
67 lines (59 loc) · 1.75 KB
/
gulpfile.babel.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
import gulp from 'gulp';
import runSequence from 'run-sequence';
import browserSync from 'browser-sync';
import del from 'del';
import gulpLoadPlugins from 'gulp-load-plugins';
const $ = gulpLoadPlugins();
const reload = browserSync.reload;
// Clean output directory
// =============================================================================
gulp.task('clean', cb => del(
['.tmp', '_dist/*', '_dist', '!dist/.git'], {
dot: true
})
);
// Compile and automatically prefix stylesheets
// =============================================================================
gulp.task('styles', () => {
const AUTOPREFIXER_BROWSERS = [
'ie >= 10',
'ie_mob >= 10',
'ff >= 35',
'chrome >= 40',
'safari >= 7',
'opera >= 23',
'ios >= 8',
'android >= 4.4',
'bb >= 10'
];
// For best performance, don't add Sass partials to `gulp.src`
return gulp.src([
'source/scss/**/*.scss',
'source/css/**/*.css'
])
.pipe($.newer('.tmp/styles'))
.pipe($.sourcemaps.init())
.pipe($.sass({
precision: 10
}).on('error', $.sass.logError))
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(gulp.dest('.tmp/styles'))
.pipe($.size({title: 'styles'}))
.pipe($.sourcemaps.write('./'))
.pipe(gulp.dest('source/css'));
});
// Standard dev task.. Watch files for changes & reload
// =============================================================================
gulp.task('watch', ['clean', 'styles'], cb => {
gulp.watch(['source/scss/**/*.{scss,css}'], ['styles', reload]);
});
// Preview production ready files locally
// =============================================================================
gulp.task('preview-prod', cb => {
browserSync({
notify: false,
open: false,
server: 'tmp',
port: '4000'
});
});