0

I have configured Grunt to use ng-annotate. What I want is to annotate all .js files in a specific directory and copy them to a new directory when the annotation is finished. However, the complete src folder is copied to the new directory. This is my configuration:

 ngAnnotate: {
        options: {
            singleQuotes: true
        },
        dist: {
            files: [{
                expand: true,
                src: ['./src/modules/*.js'],
                dest: './src/min-safe',
                ext: '.annotated.js',
                extDot: 'last'
            }],
        }
    }

This way, I have a min-safe folder with src/modules and the annotated files. How can I just copy the annotated files into min-safe directly?

YourReflection
  • 375
  • 7
  • 22

1 Answers1

2

Grunt's src and dest options can be confusing, but they are consistent across plugins (or they are, at least, supposed to be). The Grunt documentation explains how those options can be used to work with files.

Your problem is that you've not specified the cwd option, so all src matches are against the project's current directory (the cwd default). When a src file is copied, the directories between the cwd and the matched file are included.

If you use this configuration, it should do what you want:

ngAnnotate: {
    options: {
        singleQuotes: true
    },
    dist: {
        files: [{
            expand: true,
            cwd: './src/modules',
            src: ['*.js'],
            dest: './src/min-safe',
            ext: '.annotated.js',
            extDot: 'last'
        }]
    }
}
cartant
  • 57,105
  • 17
  • 163
  • 197