diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index 34e9efabb7..0ec0fef386 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -34,6 +34,11 @@ module.exports = { regenerator: true, // Resolve the Babel runtime relative to the config. moduleName: path.dirname(require.resolve('babel-runtime/package')) + }], + // resolve imports beginning with ~ as /src/{import} + [require.resolve('babel-root-import'), { + 'rootPathPrefix': '~', + 'rootPathSuffix': 'src' }] ] }; diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index f0ead1f3b5..2f47e24c82 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -20,6 +20,7 @@ "babel-plugin-transform-runtime": "6.15.0", "babel-preset-latest": "6.14.0", "babel-preset-react": "6.11.1", + "babel-root-import": "^4.1.3", "babel-runtime": "6.11.6" } }