-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
58 lines (52 loc) · 1.54 KB
/
gulpfile.js
File metadata and controls
58 lines (52 loc) · 1.54 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const browserSync = require('browser-sync').create();
const webpack = require('webpack')
const webpackConfig = require('./webpack.config.js')
const ghPages = require('gulp-gh-pages');
// compile scss into css
function style() {
return gulp.src('./scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./css'))
.pipe(browserSync.stream());
}
// start server and watch file changes
// function watch() {
// browserSync.init({
// server: {
// baseDir: './'
// }
// });
// gulp.watch('./scss/**/**.scss', style);
// gulp.watch('./*.html').on('change', browserSync.reload);
// gulp.watch('./js/**/*.js').on('change', browserSync.reload);
// }
function assets(cb) {
return new Promise((resolve, reject) => {
webpack(webpackConfig, (err, stats) => {
if (err) {
return reject(err)
}
if (stats.hasErrors()) {
return reject(new Error(stats.compilation.errors.join('\n')))
}
resolve()
})
})
}
function watch() {
browserSync.init({
server: {
baseDir: './dist'
}
});
gulp.watch(['./src/scss/**/*.scss','./src/*.html', './src/js/**/*.js']).on('change',gulp.series(assets, browserSync.reload)) ;
}
function deploy() {
return gulp.src('./dist/**/*').pipe(ghPages());
}
exports.style = style;
exports.build = assets;
exports.watch = watch;
exports.deploy = deploy;