-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (61 loc) · 2.05 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
const rename = require('gulp-rename');
const browserSync = require('browser-sync').create();
const browserReload = browserSync.reload;
// Task to compile scss to CSS and copy to the dist folder
function scssTask(){
return gulp.src('src/scss/main.scss')
.pipe(sourcemaps.init())
.pipe(sass({
errLogToConsole: true
}))
.on ( 'error', console.error.bind( console ))
.pipe(autoprefixer())
.pipe(rename( { suffix: '.min' } ))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/css/'))
.pipe(browserSync.stream());
}
// Task to copy the HTML file to the dist folder as it is
function htmlTask(){
return gulp.src('src/*.html')
.pipe(gulp.dest('dist/'));
}
// Task to copy the JS files to the dist folder as it is
function jsTask(){
return gulp.src('src/js/*.js')
.pipe(gulp.dest('dist/js/'));
}
// Task to copy the Intial Bootstrap JS files and its dependancy to the dist folder
function bootstrapTask(){
return gulp.src('node_modules/bootstrap/dist/js/bootstrap.min.js')
.pipe(gulp.dest('src/js/'));
}
// Look for the changes
// function watch(){
// browserSync.init({
// server: {
// baseDir: './dist/'
// }
// });
// gulp.watch( 'src/scss/', scssTask);
// gulp.watch( 'src/*.html', htmlTask);
// gulp.watch('src/js/*.js', jsTask);
// gulp.watch('src/*.html').on('change', browserReload);
// }
// exports.watch = watch;
// gulp.task("default", watch);
gulp.task('default', gulp.series(scssTask, htmlTask, jsTask, function() {
browserSync.init({
server: {
baseDir: './dist/'
}
});
gulp.watch( 'src/scss/', scssTask);
gulp.watch( 'src/*.html', htmlTask);
gulp.watch('src/js/*.js', jsTask);
gulp.watch('src/*.html').on('change', browserReload);
}));