动态生成文件名
-
expand设置为true打开以下选项 -
cwd所有src指定的文件相对于这个属性指定的路径 -
src要匹配的路径,相对与cwd -
dest生成的目标路径前缀 -
ext替换所有生成的目标文件后缀为这个属性 -
flatten删除所有生成的dest的路径部分 -
rename一个函数,接受匹配到的文件名,和匹配的目标位置,返回一个新的目标路径
grunt.initConfig({ minify: { dynamic_mappings: { // Grunt will search for "**/?.js" under "lib/" when the "minify" task runs files: [ { expand: true, // Enable dynamic expansion. cwd: 'lib/' // Src matches are relative to this path. src: ['**/?.js'], // Actual pattern(s) to match. dest: 'build/', // Destination path prefix. ext: '.min.js', // Dest filepaths will have this extension. } ] } } });
原文:http://www.hulufei.com/post/grunt-introduction