Compiling multiple files with babel

Simple example: I want to use babel (via grunt) to compile all files in a folder without having to list the files one by one. How should I do it? I have looked through basically all the Babylon documents (and many 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 should I do it? I don't care if it's all in one file or separate files, since the files will end up being merged together. Thanks in advance.

Edit: just to clarify, I'm talking about Babel 6.

+3


source to share


1 answer


To map every single file you could use:



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

      

+1


source







All Articles