-
Install babel plugin module resolver using the below code
- npm install --save-dev babel-plugin-module-resolver
-
Install customize cra and react wired using
- npm install customize-cra react-app-rewired --dev
-
create the .babelrc in the src folder or in project directory and create the alias using the below sample code
{ "plugins": [ ["module-resolver", { "root": ["./"], "alias": { "components": "./src/components", "Containers": "./src/containers", "Views": "./src/views", "Routes": "./src/routes" } }] ] }
-
In the package.json file change the following code to
"scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", }
"scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", "test": "react-app-rewired test", }
-
Create the new file naming config.overrides.js and paste the below code
const { useBabelRc, override } = require("customize-cra"); module.exports = override(useBabelRc());
-- This will actually say to Webpack to use this custom .babelrc file.
Yogen-Pokhrel/Import-React-Components-Using-Absolute-Path
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Sample Code in this repository helps you to use Absolute Paths while importing components in react
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published