我正在使用 https://github.com/jney/grunt-htmlcompressor来压缩HTML文件.但它需要我手动输入我想要缩小的所有HTML文件: grunt.initConfig({ htmlcompressor: { compile: { files: { 'dest/index.html': 'src/index.html' },
          grunt.initConfig({
  htmlcompressor: {
    compile: {
      files: {
        'dest/index.html': 'src/index.html'
      },
      options: {
        type: 'html',
        preserveServerScript: true
      }
    }
  }
}); 
 有没有办法指定我想缩小整个文件夹(和子文件夹)的所有HTML文件?
或者,如果这个html压缩器是有限的,你知道一个不同的npm包来做这个HTML mification吗?
默认情况下,应允许 glob pattern执行任何grunt任务.然后只需使用 dynamic files将每个构建到您的dest代替:
files: {
        'dest/index.html': 'src/index.html'
      }, 
 跟着:
files: [
        {
          expand: true,     // Enable dynamic expansion.
          cwd: 'src/',      // Src matches are relative to this path.
          src: ['**/*.html'], // Actual pattern(s) to match.
          dest: 'dest/',   // Destination path prefix.
        },
      ], 
 至于另一个插件我会推荐grunts contrib version,因为它更常见并由咕噜团队维护.
