'Is there possible way to add base url for imports in react js?
Normal way adding imports:
import Sample from ‘../../../components/signup’
I need to imports without front dots and slashes:
import Component from ‘components/signup’
Can I add base url for imports to solve this problem? Is it the right way? Or if there a solution please leave the answer below.
Solution 1:[1]
If you use Webpack, you can add the below code snippet into your webpack.config.js
resolve: {
alias: {
components: path.resolve(__dirname, 'src/components/')
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
