1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/server/build/babel/find-config.js

17 lines
672 B
JavaScript
Raw Normal View History

import { join } from 'path'
import buildConfigChain from 'babel-core/lib/transformation/file/options/build-config-chain'
export default function findBabelConfig (dir) {
// 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')
return configList[0]
}