好吧,我已经坚持了两个星期,所以希望这里的其他人遇到过这个问题.我正在尝试使用Grunt来仅复制已更改的文件.我已经看过很多关于如何使用JSLINT和UGLIFY执行此操作的示例,但没有关于如何使用grunt-contrib-copy执行此操作的具体示例.
当您注册监视事件并将文件名传递给复制子任务时,文件名可以访问(我正在将其注销),但文件永远不会正确复制.
我希望它是一件我能忽视的简单事物.有人可以看看我的代码,看看我做错了什么?
//Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
options: {
base: 'app',
dist: 'dist',
},
copy: {
changedFiles: {
expand: true,
dot: true,
cwd: '<%= options.base %>',
src: ['**/*.*'],
dest: '<%= options.dist %>/'
}
},
watch: {
options: {
nospawn: true,
//debounceDelay: 1000,
},
css: {
files: ['app/css/*.css',
'app/js/*.js'
],
tasks: ['copy:changedFiles'],
}
}
});
grunt.event.on('watch', function(action, filepath, target){
grunt.log.writeln('target: ', target + '\n filepath: ' + filepath + '\n action: has ' + action);
grunt.config('copy.changedFiles.src', new …Run Code Online (Sandbox Code Playgroud)