-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
69 lines (58 loc) · 1.42 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
const gulp = require('gulp');
const del = require('del');
const rename = require('gulp-rename');
const postcss = require('gulp-postcss');
const path = require('path');
const plumber = require('gulp-plumber');
const browserSync = require('browser-sync').create();
const reload = browserSync.reload;
const src = 'src';
const dest = 'dist';
gulp.task('serve', () => {
browserSync.init({
server: {
baseDir: dest
},
notify: false
});
gulp.watch(`${src}/styles/**/*.pcss`, ['styles']);
gulp.watch(`${src}/*.html`, ['html', 'reload']);
gulp.watch(`${src}/scripts/**/*.js`, ['scripts', 'reload']);
});
gulp.task('reload', (done) => {
reload();
done();
})
gulp.task('default', ['clean', 'build']);
gulp.task('build', ['html', 'styles', 'scripts', 'images']);
gulp.task('clean', () => {
return del([
path.join(dest, '**/*')
]);
});
gulp.task('html', () => {
return gulp.src(`${src}/*.html`, {
base: src
})
.pipe(gulp.dest(dest));
});
gulp.task('styles', () => {
return gulp.src(`${src}/styles/*.pcss`)
.pipe(plumber())
.pipe(postcss())
.pipe(rename({
extname: '.css'
}))
.pipe(gulp.dest(dest))
.pipe(reload({
stream: true
}));
});
gulp.task('scripts', () => {
return gulp.src(`${src}/scripts/**/*.js`)
.pipe(gulp.dest(`${dest}`));
});
gulp.task('images', () => {
return gulp.src(`${src}/images/*.png`)
.pipe(gulp.dest(`${dest}/images`));
});