-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
67 lines (59 loc) · 1.67 KB
/
gulpfile.js
File metadata and controls
67 lines (59 loc) · 1.67 KB
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
var gulp = require("gulp");
var pug = require('gulp-pug');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var notify = require("gulp-notify");
var plumber = require("gulp-plumber");
var browserSync = require("browser-sync");
//setting : paths
var paths = {
'sass': './src/sass/',
'css': './dist/css/',
'pug': './src/pug/',
'html': './dist/',
'js': './dist/js/'
}
//setting : Sass Options
var sassOptions = {
// outputStyle: 'compressed'
}
//setting : Pug Options
var pugOptions = {
pretty: true
}
//Sass
gulp.task('sass', function () {
gulp.src([paths.sass + '**/*.scss', paths.sass + '**/*.sass'])
.pipe(plumber({ errorHandler: notify.onError("Error: <%= error.message %>") }))
.pipe(sass(sassOptions))
.pipe(autoprefixer())
.pipe(gulp.dest(paths.css))
});
//Pug
gulp.task('pug', () => {
return gulp.src([paths.pug + '**/*.pug', '!' + paths.pug + '**/_*.pug'])
.pipe(plumber({ errorHandler: notify.onError("Error: <%= error.message %>") }))
.pipe(pug(pugOptions))
.pipe(gulp.dest(paths.html));
});
//Browser Sync
gulp.task('browser-sync', () => {
browserSync({
server: {
baseDir: paths.html
}
});
gulp.watch(paths.html + "**/*.html", ['reload']);
gulp.watch(paths.css + "**/*.css", ['reload']);
gulp.watch(paths.js + "**/*.js", ['reload']);
});
gulp.task('reload', () => {
browserSync.reload();
});
//watch
gulp.task('watch', function () {
// gulp.watch([paths.pug + '**/*.pug', '!' + paths.pug + '**/_*.pug'], ['pug']);
gulp.watch([paths.sass + '**/*.scss', paths.sass + '**/*.sass'], ['sass']);
gulp.watch(paths.pug + '**/*.pug', ['pug']);
});
gulp.task('default', ['browser-sync', 'watch']);