grunt init copyAndProcess损坏png文件



我刚刚开始使用grunt init。除了我发现模板中的任何图像/*.png文件在传输到目标文件夹的过程中都被损坏外,我的一切都正常工作。

我怀疑init.copyAndProcess函数正在损坏它们(它们在Gimp中从模板文件夹打开,但不是从目标文件夹打开)。

如何对模板中的文件子集执行复制而不是copyAndProcess?最好使用类似"images/**"的模式来识别文件。

您实际上可以使用filesToCopy,因为您传递了一个noprocess散列,告诉grunt init它不应该处理的文件。

请参阅http://gruntjs.com/project-scaffolding#copying-文件(grunt init文档)以及本次提交第73行的一个示例https://github.com/gruntjs/grunt-init-jquery/blob/ecf070d7469d610441458111bc05cd543ee5bbc0/template.js.

好吧,我更喜欢更简洁的东西,类似于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 );
});

最新更新