-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
48 lines (41 loc) · 1.26 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
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var babel = require('gulp-babel');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var wrap = require('gulp-wrap');
function reportChange(event){
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
}
gulp.task('build-html', function() {
gulp.src(['./src/html/**/*.html', '!./src/html/layout.html'])
.pipe(wrap({src: './src/html/layout.html'}))
.pipe(gulp.dest('./'));
});
gulp.task('build-sass', function() {
gulp.src('src/css/**/*.scss')
.pipe(sass())
.pipe(concat('app.css'))
.pipe(gulp.dest('dest/css'));
});
gulp.task('build', ['build-sass', 'build-html'], function(){
browserSync.reload();
});
gulp.task('serve', ['build'], function(done) {
browserSync({
open: false,
port: 9000,
server: {
baseDir: ['.'],
middleware: function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
}
}
}, done);
});
gulp.task('watch', ['serve'], function() {
gulp.watch(['src/html/**/*.html','src/js/**/*.js', 'src/css/**/*.scss'], ['build']).on('change', reportChange);
});
gulp.task('default', ['build']);