Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup grunt-babel to transpile an entire directory

Tags:

So I have this in my gruntfile:

gruntConfig.babel = {
        options: {
            sourceMap: true
        },
        dist: {
            files: {
                "dist/server.js": "src/*.js"
            }
        }
    };

This correctly transpiles all the js files in src, but it overwrites dist/server.js every time.

This must be really simple, but I can't seem to figure out how to make it write to different output files, one for each sourcefile.

like image 207
Flion Avatar asked May 19 '15 13:05

Flion


1 Answers

It's can be achieved by using dynamic files mapping.

For your case config will look like this:

gruntConfig.babel = {
    options: {
        sourceMap: true
    },
    dist: {
        files: [
            {
                expand: true,
                cwd: 'src/',
                src: ['*.js'],
                dest: 'dist/'
            }
        ]
    }
};
like image 97
raidendev Avatar answered Sep 20 '22 16:09

raidendev