-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
77 lines (57 loc) · 1.59 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
75
76
77
var gulp = require('gulp');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var pug = require('gulp-pug');
var browserSync = require('browser-sync').create();
var paths = {
css: {
all: './src/scss/**/*.scss',
src: './src/scss/*.scss',
dist: './dist/assets/css'
},
js: {
all: './src/scripts/**/*.js',
src: './src/scripts/*.js',
dist: './dist/assets/js'
},
pug: {
all: './src/pug/**/*.pug',
src: './src/pug/*.pug',
dist: './dist'
}
}
// BrowserSync Task
gulp.task('browserSync', function() {
browserSync.init({
server: { baseDir: 'dist' }
})
});
gulp.task('sass', function () {
return gulp.src(paths.css.src)
.pipe(sass({
outputStyle: 'expanded'
}).on('error', sass.logError))
// prefix styles
.pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(gulp.dest(paths.css.dist))
.pipe(browserSync.reload({stream: true}));
});
// move src scripts files to dist folder
gulp.task('scripts', function () {
return gulp.src(paths.js.src)
.pipe(gulp.dest(paths.js.dist))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('pug', function () {
return gulp.src(paths.pug.src)
.pipe(pug({ pretty: true }))
.pipe(gulp.dest(paths.pug.dist))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('watch', function () {
gulp.watch(paths.css.all, ['sass']);
gulp.watch(paths.js.all, ['scripts']);
gulp.watch(paths.pug.all, ['pug']);
});
gulp.task('build', ['sass', 'scripts', 'pug']);
gulp.task('default', ['build', 'watch', 'browserSync']);