0

I am using grunt-contrib-copy to copy folders and files from my src folder to build folder. But I want to exclude all .js files from the app subdirectory in my src directory. This is my Gruntfile. But it is copying all .js files from the subdirectories in app directory instead of excluding. What changes should I make to make it work.

This is my grunt file:

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']);
};

Reference: Configure grunt copy task to exclude files/folders

Thanks.

Community
  • 1
  • 1
Unferth
  • 4,638
  • 1
  • 14
  • 14

1 Answers1

1

Can you try to remove the first slash after the exclamation mark? So change this:

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

to this:

'!src/app/**/*.js'
Lajos Veres
  • 13,595
  • 7
  • 43
  • 56