grunt-contrib-clean不删除单个文件

时间:2015-12-22 19:18:06

标签: javascript gruntjs

使用load-grunt-config拆分我的Grunt配置,我创建了一个clean.js来删除一些带有grunt-contrib-clean的文件和文件夹,以便进行全新的重建:

module.exports = {
   deleteFiles: {
     build: [
       '<%= srcPath %>css', 
       '<%= gruntPath %>*.js', // Not working
       '<%= distPath %>css', 
       '<%= distPath %>img', 
       '<%= testPath %>*',  // Not working
       '!<%= testPath %>.scss-lint.yml', 
       'test.js' // Not working
    ]
  }
};

在Gruntfile的数据块中指定了路径:

srcPath: 'src/'
distPath: 'dist/'
testPath: 'test/'
gruntPath: 'grunt/'

运行清洁任务时,仅删除指定的文件夹,但不删除*.js, *test.js

等单个文件

知道可能出现什么问题吗?

1 个答案:

答案 0 :(得分:1)

使用**代替一个(*)来包含所有子文件夹和文件

E.g

module.exports = {
   deleteFiles: {
     build: [
       '<%= srcPath %>css', 
       '<%= gruntPath %>**/*.js', 
       '<%= distPath %>css', 
       '<%= distPath %>img', 
       '<%= testPath %>**', 
       '!<%= testPath %>.scss-lint.yml', 
       'test.js'
    ]
  }
};

或只是使用/指定文件夹的名称。 E.g test代替test/

关于test.js文件,请确保路径正确。它没有理由不起作用

相关问题