Search code examples
gulpbabeljsrollup

Is it possible to use two .babelrc files?


I have a project that runs both a build using rollup and a build using browserify for two different outputs. Now, they are both located in the same root dir and I have separate gulp-tasks running for both of them. My problem is that my browserify task wants a .babelrc file with the following configuration:

{
  "presets": ["es2015"]
}

and my rollup task wants this configuration:

{
  "presets": ["es2015-rollup"]
}

My question is, can I have two separate .babelrc files and configure which one to use in my gulp and karma config?


Solution

  • I looked around a lot before asking this question and right after I posted I found a possible solution:

    gulp.task('rollup', () => {
      return gulp.src('src/server/index.js', { read: false })
        .pipe(rollup({
          plugins: [babel({
            presets: ["es2015-rollup"],
            babelrc: false
          })]
        }))
        .pipe(gulp.dest('public/'));
    });
    

    By configuring one of the tasks to not use the babelrc I could of course configure it myself directly. This isn't a great answer and I would've preferred to just added the name of a babelrc file.