blendid icon indicating copy to clipboard operation
blendid copied to clipboard

Move babel config to a .babelrc file

Open greypants opened this issue 8 years ago • 3 comments

Other packages like Jest expect this file to exist if you're using babel. This would make sharing babel settings easier.

greypants avatar Jan 23 '17 20:01 greypants

This miiiiiight already work. I think .babelrc files trump the config if they exist. Need to test further though.

greypants avatar May 01 '17 14:05 greypants

I confirmed that from a small testing project, using .babelrc seemed to have work wonderfully.

maoueh avatar Jun 04 '17 13:06 maoueh

After further testing, it appears that not everything is picked up. It seems that plugins does not work when used inside the .babelrc file.

In .babelrc, this was not working:

$ cat .babelrc
{
  "presets": ["react-app"],
  "plugins": ["transform-decorators-legacy"]
}

While this is working:

  javascripts: {
    entry: {
      app: ['./app.js'],
    },
    babel: {
      presets: ['react-app'],
      plugins: ['transform-decorators-legacy'],
    },
  },

Also, I tested to see what would happen if I mixed stuff. This test seems to point there is some kind of merging happening as this setup is also working correctly:

$ cat .babelrc
{
  "presets": ["react-app"]
}
  javascripts: {
    entry: {
      app: ['./app.js'],
    },
    babel: {
      plugins: ['transform-decorators-legacy'],
    },
  },

So the presets and plugins were merged in a single config but specifying plugins in .babelrc does not seem to work as expected.

maoueh avatar Jun 05 '17 03:06 maoueh