[英]Grunt Task - Movig files from one folder to another
我在编写本机functino时遇到问题,该函数会将我的文件从一个目录复制到另一个目录,并排除正在处理的某些文件和目录。
module.exports = function(grunt) {
grunt.initConfig({
//....
copy: {
prod: {
src: ["./src/*"],
dest: ["build/"]
}
}
}
}
这是我的自定义任务负载:
grunt.loadNpmTasks('copy', function(){
var src = grunt.config.get('copy.src'),
dest = grunt.config.get('copy.dest'),
grunt.file.copy(src, dest);
});
我在控制台中收到此错误:
警告:找不到任务“复制”。
我虽然这是本机的咕unt功能,但功能仍然是: http ://gruntjs.com/api/grunt.file
然后我的产品看起来像这样:
grunt.registerTask("prod", ["concat", "uglify", "htmlmin", "imagemin", "copy"]);
我猜这毕竟不是本地的咕unt功能。 您可以安装“复制”,而无需编写自定义任务加载功能。
从以下位置安装副本:
npm install grunt-contrib-copy --save-dev
有关插件的更多信息,请访问: https : //github.com/gruntjs/grunt-contrib-copy
我将初始化中的复制任务重新配置为此:
copy: {
prod: {
files: [
{expand: true, src: ['./src/**'], dest: 'build/'}
]
}
}
并包括
grunt.loadNpmTasks('grunt-contrib-copy');
就这样。 现在可以使用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.