-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·83 lines (72 loc) · 2.12 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
78
79
80
81
82
83
const gulp = require('gulp');
const sass = require('gulp-sass');
const gulpsync = require('gulp-sync')(gulp);
const clean = require('gulp-clean');
const watch = require('gulp-watch');
const browserSync = require('browser-sync').create();
const importCss = require('gulp-cssimport');
const sourcemaps = require('gulp-sourcemaps');
const pug = require('gulp-pug');
const imagemin = require('gulp-imagemin');
const distFolder = './build/';
sass.compiler = require('node-sass');
gulp.task('watch', function () {
watch(['./src/assets/scss/**/*.scss'], () => {
gulp.run('sass');
browserSync.reload();
});
watch(['./src/assets/images/**/*.*'], () => {
gulp.run('images');
browserSync.reload();
});
watch(['./src/assets/fonts/**/*.*'], () => {
gulp.run('fonts');
browserSync.reload();
});
watch(['./*.html'], () => {
gulp.run('copy');
browserSync.reload();
});
watch(['./src/**/*.pug'], () => {
gulp.run('pug');
browserSync.reload();
});
});
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "./build"
}
});
});
gulp.task('clean', function () {
return gulp.src([distFolder + '/css', distFolder + '/fonts', distFolder + '/images'], {read: false})
.pipe(clean({
force: true,
}));
});
gulp.task('sass', function () {
return gulp.src('./src/assets/scss/app.scss')
.pipe(sass().on('error', sass.logError))
.pipe(importCss({}))
.pipe(gulp.dest(distFolder + 'css'));
});
gulp.task('fonts', function () {
gulp.src('./src/assets/fonts/**/*.*')
.pipe(gulp.dest(distFolder + 'fonts'));
});
gulp.task('images', function () {
gulp.src('./src/assets/images/**/*.*')
.pipe(imagemin())
// .pipe(image())
.pipe(gulp.dest(distFolder + 'images'));
});
gulp.task('copy', function () {
gulp.src('./*.html')
.pipe(gulp.dest('./build/'));
});
gulp.task('pug', () => {
return gulp.src('./src/templates/pages/*.pug').pipe(pug()).pipe(gulp.dest('./build/'));
});
gulp.task('build', gulpsync.sync(['clean', 'pug', 'sass', 'images', 'fonts']));
gulp.task('dev', gulpsync.sync(['build', 'watch', 'browser-sync']));