出于某种原因,当我使用“gulp”命令时,它最终没有“观察”。我希望它在更改文件时刷新页面。这是我的gulpfile:
//Gulp
var gulp = require('gulp'),
//Plugins
sass = require('gulp-sass'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
fileInclude = require('gulp-file-include'),
imageMin = require('gulp-imagemin');
//Sass
gulp.task('sass', function() {
return gulp.src('source/assets/sass/**/*.scss')
.pipe(sass({
style: 'compressed'
}))
.pipe(gulp.dest('./build/assets/css'))
});
//Concatenate and minify the Js Plugins
gulp.task('jsplugins', function() {
return gulp.src('source/assets/js/plugins/*.js')
.pipe(concat('plugins.js'))
.pipe(gulp.dest('./build/assets/js'))
.pipe(rename('plugins.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./build/assets/js/'));
});
//Minify main JS
gulp.task('jsmain', function() {
return gulp.src('source/assets/js/main.js')
.pipe(uglify())
.pipe(rename('main.min.js'))
.pipe(gulp.dest('./build/assets/js'));
});
//Images
gulp.task('images', function() {
return gulp.src('source/assets/images/**.*')
.pipe(imageMin({progressive: true}))
.pipe(gulp.dest('build/assets/images/'))
});
//Includes
gulp.task('fileInclude', function() {
gulp.src(['source/*.html'])
.pipe(fileInclude({prefix: '@@',basepath: '@file'}))
.pipe(gulp.dest('./build'));
});
//Main Watch
gulp.task('watch', function() {
gulp.watch('source/assets/sass/**/*.scss', ['sass']);
gulp.watch('source/*.html', ['fileInclude']);
gulp.watch('source/assets/js/main.js', ['jsmain']);
gulp.watch('source/assets/js/plugins/*.js', ['jsplugins']);
gulp.watch('source/assets/images/**.*', ['images']);
});
//Main Command
gulp.task('default', ['sass', 'jsplugins','jsmain', 'images','fileInclude', 'watch'], function() {
process.exit(0);
});
这是我在运行“gulp”时得到的输出:
[09:57:44] Using gulpfile ~/Sites/elonco-35359-LOOC-Art-Manage-
Kit/gulpfile.js
[09:57:44] Starting 'sass'...
[09:57:44] Starting 'jsplugins'...
[09:57:44] Starting 'jsmain'...
[09:57:44] Starting 'images'...
[09:57:44] Starting 'fileInclude'...
[09:57:44] Finished 'fileInclude' after 3.1 ms
[09:57:44] Starting 'watch'...
[09:57:44] Finished 'watch' after 21 ms
[09:57:44] Finished 'jsplugins' after 52 ms
[09:57:45] Finished 'jsmain' after 131 ms
[09:57:45] Finished 'sass' after 163 ms
[09:57:45] gulp-imagemin: Minified 2 images (saved 5.27 kB - 44.4%)
[09:57:45] Finished 'images' after 178 ms
[09:57:45] Starting 'default'...
我不确定为什么手表最后没有运行。
答案 0 :(得分:0)
我修好了。出于某种原因,它实际上是观看但似乎不是。不知道为什么一开始就发生了。它可能是我删除后的另一个插件。