【问题标题】:How to configure grunt copy task to exclude .js files from a subdirectory如何配置 grunt 复制任务以从子目录中排除 .js 文件
【发布时间】:2014-04-21 07:23:35
【问题描述】:

我正在使用grunt-contrib-copy 将文件夹和文件从我的src 文件夹复制到build 文件夹。但我想从我的src 目录中的app 子目录中排除所有.js 文件。 这是我的 Gruntfile。但它是从 app 目录中的子目录复制所有 .js 文件,而不是排除。我应该进行哪些更改才能使其正常工作。

这是我的 grunt 文件:

module.exports = function(grunt) {
  grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
    // Task configuration.
concat: {
  dist: {
    src: ['src/app/**/*.js'],
    dest: 'build/app.min.js'
  }
},
    copy: {
    main: {
      files: [
         //includes files within path and its sub-directories
            //{src: ['src/**', '!/src/app/**/*.js'], dest: 'build/', filter: 'isFile'}
        {expand: true, src: ['src/**', '!/src/app/**/*.js'], dest: 'build/', filter: 'isFile'}
      ]
    }
} 
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
 grunt.registerTask('default', ['concat', 'copy']);
};

参考:Configure grunt copy task to exclude files/folders

谢谢。

【问题讨论】:

    标签: javascript copy gruntjs grunt-contrib-copy


    【解决方案1】:

    您可以尝试删除感叹号后的第一个斜线吗?所以改变这个:

    '!/src/app/**/*.js'
    

    到这里:

    '!src/app/**/*.js'
    

    【讨论】:

      猜你喜欢
      • 2013-02-18
      • 2023-04-10
      • 2014-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多