Gruntjs grunt init copyAndProcess损坏png文件
我刚刚开始使用grunt init。我的一切都正常工作,除了发现模板中的所有图像/*.png文件在传输到目标文件夹时损坏 我怀疑init.copyAndProcess函数正在损坏它们(它们在Gimp中从模板文件夹打开,但不是从目标文件夹打开)Gruntjs grunt init copyAndProcess损坏png文件,gruntjs,Gruntjs,我刚刚开始使用grunt init。我的一切都正常工作,除了发现模板中的所有图像/*.png文件在传输到目标文件夹时损坏 我怀疑init.copyAndProcess函数正在损坏它们(它们在Gimp中从模板文件夹打开,但不是从目标文件夹打开) 如何对模板中的文件子集进行复制而不是copyAndProcess?最好使用像“images/**”这样的模式来识别文件。好吧,我更希望使用更简洁的模式,类似于template.js中已有的模式: var files = init.filesToCopy(
如何对模板中的文件子集进行复制而不是copyAndProcess?最好使用像“images/**”这样的模式来识别文件。好吧,我更希望使用更简洁的模式,类似于template.js中已有的模式:
var files = init.filesToCopy( props );
init.copyAndProcess( files, props );
但这是可行的:
var src_path = init.srcpath( 'images/' );
var dest_path = init.destpath( ) + '/images/';
// Copy the images folder this way to prevent corrupting the files
grunt.file.recurse( src_path, function( abspath, rootdir, subdir, filename ) {
if ( subdir == undefined ) {
var dest = dest_path + filename;
} else {
var dest = dest_path + subdir + '/' + filename;
}
grunt.file.copy( abspath, dest );
});
实际上,您可以使用filesToCopy,因为您传递了一个noprocess散列,告诉grunt init它不应该处理的文件 请参阅(grunt初始化文档)
第73行是这个提交的一个例子。下面是第73行的内容:init.copyAndProcess(文件、道具,{noProcess:'libs/**});