pgpv
pgpv

Reputation: 385

Compiling several files with babel

Simple example: I want to use babel (via grunt) to compile all of the files in a folder without having to specify the files one by one. How do I do this? I have looked at basically all of Babel's docs (and lots of other places) and found nothing.

I know I can do this:

'dist/folder/a.js': 'folder/a.js',
'dist/folder/b.js': 'folder/b.js',
'dist/folder/c.js': 'folder/c.js'

but what I want to do is something like:

'dist/folder/': 'folder/*.js',

I also tried the following approach but it stops after the first file:

'dist/folder/alltogethernow.js': 'folder/*.js',

How do I do this? I don't really care if it's all in the same file or separate files as the files will eventually be merged together anyway. Thanks in advance.

Edit: Just to clarify, I'm talking about babel 6.

Upvotes: 3

Views: 2266

Answers (1)

Revive
Revive

Reputation: 2248

To map each individual file you could use:

babel: {
    options: {
        sourceMap: true,
        presets: ['es2015'] 
    },
    dist: {
         files: [{
            expand: true,  
            src: ['folder/*.js'], 
            dest: 'dist'
          }]
    }
},

Upvotes: 1

Related Questions