-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
70 lines (61 loc) · 1.47 KB
/
gulpfile.js
File metadata and controls
70 lines (61 loc) · 1.47 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
68
69
70
const gulp = require('gulp'),
prefixer = require('gulp-autoprefixer'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
rimraf = require('rimraf'),
gulpIf = require('gulp-if'),
browserSync = require('browser-sync'),
reload = browserSync.reload;
const path = {
build: {
html: 'build/',
css: 'build/css/',
},
src: {
html: 'src/*.html',
css: 'src/css/style.scss',
},
watch: {
html: 'src/**/*.html',
css: 'src/css/**/*.scss',
},
clean: './build'
};
const isDev = !process.env.NODE_ENV || process.env.NODE_ENV == 'dev';
gulp.task('html:build', function () {
return gulp.src(path.src.html)
.pipe(gulp.dest(path.build.html))
.pipe(reload({stream: true}));
});
gulp.task('css:build', function () {
return gulp.src(path.src.css)
.pipe(gulpIf(isDev, sourcemaps.init()))
.pipe(sass())
.pipe(prefixer())
.pipe(gulpIf(isDev, sourcemaps.write()))
.pipe(gulp.dest(path.build.css))
.pipe(reload({stream: true}));
});
gulp.task('build', [
'clean',
'html:build',
'css:build',
]);
gulp.task('browserSync', function() {
browserSync({
server: {
baseDir: "./build"
},
port: 8080,
open: true,
notify: false
});
});
gulp.task('watch', function(){
gulp.watch(path.watch.html, ['html:build']);
gulp.watch(path.watch.css, ['css:build']);
});
gulp.task('clean', function (cb) {
rimraf(path.clean, cb);
});
gulp.task('default', ['build', 'watch', 'browserSync']);