2017-02-03 05:33:35 +00:00
|
|
|
import { join } from 'path'
|
|
|
|
import buildConfigChain from 'babel-core/lib/transformation/file/options/build-config-chain'
|
|
|
|
|
2017-02-12 21:18:22 +00:00
|
|
|
export default function findBabelConfig (dir) {
|
2017-02-03 05:33:35 +00:00
|
|
|
// We need to provide a location of a filename inside the `dir`.
|
|
|
|
// For the name of the file, we could be provide anything.
|
|
|
|
const filename = join(dir, 'filename.js')
|
|
|
|
const options = { babelrc: true, filename }
|
|
|
|
|
|
|
|
// First We need to build the config chain.
|
|
|
|
// Then we need to remove the config item with the location as "base".
|
|
|
|
// That's the config we are passing as the "options" below
|
|
|
|
const configList = buildConfigChain(options).filter(i => i.loc !== 'base')
|
|
|
|
|
2017-02-12 21:18:22 +00:00
|
|
|
return configList[0]
|
2017-02-03 05:33:35 +00:00
|
|
|
}
|