When running npx babel index.js
from the command line, I was hoping I would see my babel configurations being applied from babel.config.js
However it does not seem the case as was wondering why this might be?
// babel.config.js
module.exports = function babel(api) {
api.cache(true);
return {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'babel-plugin-root-import',
{
rootPathSuffix: './src',
rootPathPrefix: '~/',
},
],
],
};
};
// index.js
import { AppRegistry } from 'react-native';
import App from '~/App';
AppRegistry.registerComponent("App Name", () => App)
// Expected output from npx babel index.js
import { AppRegistry } from 'react-native';
import App from './src/App'; // Note the change from '~' to './src' using babel-plugin-root-import
AppRegistry.registerComponent("App Name", () => App)
I noticed in the npx babel --help it stated that --no-babelrc flag ignores configuration from .babelrc and .babelignore files. Does this suggest that babel.config.js files aren't considered when calling this command?
Cheers
npx babel --version
gave 6.26.0 (babel-core 6.26.3) – Elmoelmore