Skip to content
This repository was archived by the owner on Mar 10, 2023. It is now read-only.

Commit 4dca9f9

Browse files
Christian LeChristian Le
authored andcommitted
Update to be able to use package.json
1 parent 456b87e commit 4dca9f9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ if (babelRootImport.default) {
2828
function getConfigFromBabel(start, babelrc = '.babelrc') {
2929
if (start === '/') return [];
3030

31+
const packageJSONPath = path.join(start, babelrc);
32+
const packageJSON = require(packageJSONPath);
33+
const babelConfig = packageJSON.babel;
34+
if (babelConfig) {
35+
const pluginConfig = babelConfig.plugins.find(p => {
36+
p[0] === 'babel-root-import'
37+
});
38+
process.chdir(path.dirname(packageJSONPath));
39+
return pluginConfig[1];
40+
}
41+
3142
const babelrcPath = path.join(start, babelrc);
3243
if (fs.existsSync(babelrcPath)) {
3344
const babelrcJson = JSON5.parse(fs.readFileSync(babelrcPath, 'utf8'));

0 commit comments

Comments
 (0)