我想用gulp写一个监视任务来观察我的服务器php文件。但我不会看整个供应商的目录。现在我的代码看起来像这样:
var paths = {
src: [
'src/**/*.html',
'src/**/*.js',
'src/**/*.css',
'src/server/**/*',
'src/server/**/.*'
],
dist: 'dist',
base: 'src',
watchSrc: [
'src/**/*.html',
'src/**/*.css',
'!src/server/vendor/**/*',
'src/server/**/*.php',
'src/server/**/.*'
]
};
gulp.task('copy:src', function() {
gulp.src('node_modules').pipe(symlink(paths.dist + '/node_modules', {force: true}));
gulp.src('src/server/vendor').pipe(symlink(paths.dist + '/server/vendor', {force: true}));
return gulp.src(paths.src, {base: paths.base}).pipe(gulp.dest(paths.dist));
});
gulp.task('clean:dist', function(cb) {
rimraf(paths.dist, cb);
});
gulp.task('watch', function() {
runSequence('clean:dist', 'copy:src');
return watch(paths.src, {verbose: true, base: paths.base}).pipe(gulp.dest(paths.dist))
});
但这对我不起作用。也许你知道如何处理这个?
答案 0 :(得分:0)
好的,我已经知道有一个复制和粘贴错误,它使用错误的路径调用监视任务:
时:
gulp.task('watch', function() {
runSequence('clean:dist', 'copy:src');
return watch(paths.src, {verbose: true, base: paths.base}).pipe(gulp.dest(paths.dist))
});
已改为:
gulp.task('watch', function() {
runSequence('clean:dist', 'copy:src');
return watch(paths.watchSrc, {verbose: true, base: paths.base}).pipe(gulp.dest(paths.dist))
});
现在似乎有效了