-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgulpfile.js
More file actions
48 lines (40 loc) · 1.26 KB
/
gulpfile.js
File metadata and controls
48 lines (40 loc) · 1.26 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
// include the required packages.
const gulp = require('gulp');
const watch = require('gulp-watch');
const browserSync = require('browser-sync').create();
const concat = require('gulp-concat');
const minify = require('gulp-minify');
const csso = require('gulp-csso');
// Default gulp task to run
gulp.task('default', ['serve']);
//process css files
gulp.task('css', function () {
return gulp.src('./src/css/*.css')
.pipe(csso())
.pipe(concat('main.css'))
.pipe(gulp.dest('./build/css/'));
});
// process js files
gulp.task('js', function () {
return gulp.src('./src/js/*.js')
.pipe(concat('main.js'))
.pipe(minify())
.pipe(gulp.dest('./build/js/'));
});
gulp.task('html', function() {
return gulp.src('./src/index.html')
.pipe(gulp.dest('./build/'))
});
gulp.task('copy_assets', function() {
return gulp.src('./src/assets/**/*')
.pipe(gulp.dest('./build/assets/'))
});
//refresh the browser when there's changes
gulp.task('serve', ['css', 'js', 'html', 'copy_assets'], function() {
browserSync.init({
server: "./build/"
});
gulp.watch('./src/js/*.js', ['js']);
gulp.watch('./src/css/*.css', ['css']);
gulp.watch(['./src/js/*.js','./src/css/*.css', './src/index.html']).on('change', browserSync.reload);
});