Gruntjs 如何在使用grunt contrib compress压缩时排除文件夹根目录并仅包含内容

Gruntjs 如何在使用grunt contrib compress压缩时排除文件夹根目录并仅包含内容,gruntjs,Gruntjs,在压缩文件夹中的所有文件时,是否有一种方法可以排除文件夹根目录 grunt.initConfig({ compress: { main: { files: [ {expand: true, src: ['dist/**', 'xyz/**']}, ] } } }); 如何将dist和xyz文件夹排除在压缩文件之外 谢谢, 帕迪在前面加了一个将否定模式: {expand: true, src: ['dist/**', '!xy

在压缩文件夹中的所有文件时,是否有一种方法可以排除文件夹根目录

grunt.initConfig({
  compress: {
    main: {
      files: [
        {expand: true, src: ['dist/**', 'xyz/**']},
      ]
    }
  }   
});
如何将dist和xyz文件夹排除在压缩文件之外

谢谢,

帕迪

在前面加了一个
将否定模式:

{expand: true, src: ['dist/**', '!xyz/**']}

请参阅:

前面加上前缀将否定模式:

{expand: true, src: ['dist/**', '!xyz/**']}

请参阅:

如果希望包含文件夹下的文件,则需要更改每个目标的
cwd
,以便将它们视为每个glob模式的根

grunt.initConfig({ compress: { main: { files: [ {cwd: 'dist/', expand: true, src: ['**']}, {cwd: 'xyz/', expand: true, src: ['**']}, ] } } }); grunt.initConfig({ 压缩:{ 主要内容:{ 档案:[ {cwd:'dist/',expand:true,src:['**']}, {cwd:'xyz/',expand:true,src:['**']}, ] } } });
如果正在查找,请排除根目录中的文件夹,然后使用
模式

如果您想要包含文件夹下的文件,您需要更改每个目标的
cwd
,以便将它们视为每个全局模式的根

grunt.initConfig({ compress: { main: { files: [ {cwd: 'dist/', expand: true, src: ['**']}, {cwd: 'xyz/', expand: true, src: ['**']}, ] } } }); grunt.initConfig({ 压缩:{ 主要内容:{ 档案:[ {cwd:'dist/',expand:true,src:['**']}, {cwd:'xyz/',expand:true,src:['**']}, ] } } }); 如果正在查找,请排除根目录中的文件夹,然后使用
Kyle提到的模式