gulp v.4.0.0 是否可以监视所在文件夹之外的文件gulpfile.js
?
在较旧的 gulp 中,可以设置文件路径../../someFile.css
并监视其更改,但在 v4 中,它不会检测到同一路径的更改。
// snip....
let rootFolder = '..\..\root\';
// Watch function
let watchThis = (filePath, gulpTasks) => {
gulp.watch(filePath, gulp.series(gulpTasks))
.on('change', function(path) {
console.log(`${chalk.blue('Changed')}: ${chalk.yellow(path)}`);
})
.on('unlink', function(path) {
console.log(`${chalk.red('Deleted')}: ${chalk.yellow(path)}`);
});
}
// Watch task configuration
let watchFiles = () => {
watchThis([`${rootFolder}/style1.scss`, `${rootFolder}/style2.scss`], 'scss')
watchThis('./js/main.js', 'js')
}
// Final watch task
gulp.task('watch', gulp.series(
'development',
gulp.parallel(
watchFiles,
'startLiveServers'
)
));
// ...snip
['../../style1.scss', '../../style2.scss']
不会检测到对文件的更改,但它们将针对'./js/main.js'
. 我错过了什么吗?