我为要重建的站点设置了非常基本的gulpfile。我使用的是gulp-file-include,但是每次更改.html文件时,我似乎都无法让它运行任务,有人可以伸出援助之手并指向正确的方向。
var gulp = require("gulp");
var sass = require("gulp-sass");
var autoprefixer = require("gulp-autoprefixer");
var uglifycss = require("gulp-uglifycss");
var browserSync = require("browser-sync").create();
var fileinclude = require("gulp-file-include");
gulp.task("sass", function() {
return gulp
.src("./src/scss/**/*.scss")
.pipe(sass())
.pipe(autoprefixer())
.pipe(uglifycss())
.pipe(gulp.dest("./build/css"))
.pipe(browserSync.stream());
});
gulp.task("fileinclude", function() {
gulp
.src(["./src/views/**/*"])
.pipe(fileinclude())
.pipe(gulp.dest("./build"))
.pipe(browserSync.stream());
});
gulp.task("watch", function() {
browserSync.init({
server: "./build"
});
gulp.watch("./src/scss/**/*.scss", ["sass"]);
gulp.watch("*.html").on("change", browserSync.reload);
gulp.watch("*.html", ["fileinclude"]);
});
gulp.task("default", ["sass", "watch"]);