-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
gulpfile.js
executable file
·43 lines (36 loc) · 1.24 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
//npm run gulp watch
const gulp = require('gulp');
const fileinclude = require('gulp-file-include');
//const sass = require('gulp-sass')(require('sass'));
const sass = require('gulp-sass')(require('node-sass'));
const formatHtml = require('gulp-format-html');
const through2 = require( 'through2' );
const touch = () => through2.obj( function( file, enc, cb ) {
if ( file.stat ) {
file.stat.atime = file.stat.mtime = file.stat.ctime = new Date();
}
cb( null, file );
});
gulp.task('fileinclude', function() {
//gulp.src(['./src/**/*.html', '!**/_*/**'])
return gulp.src(['./src/*.html', './src/**/*.html', '!**/_*/**'])
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(formatHtml())
.pipe( touch() )//change file time to force html vtpl recompile
.pipe(gulp.dest('./'));
});
gulp.task('sass', function() {
//gulp.src(['./src/**/*.html', '!**/_*/**'])
return gulp.src(['./scss/*.scss'])
.pipe(sass())
.pipe(gulp.dest('./css'));
});
gulp.task('watch', function () {
gulp.watch(['./src/*.html', './src/**/*.html'], gulp.series('fileinclude'));
gulp.watch(['./scss/*.scss'], gulp.series('sass'));
});
// Default Task
gulp.task('default', gulp.series('fileinclude', 'sass'));