Import project assets using absolute paths from the project root
npm install absolute-importsImport project assets using absolute paths from the project root.
So this…
``js`
const dateUtil = require('../../../utils/date')
…becomes…
`js`
const dateUtil = require('org-app/utils/date')
#### Support
Works with React Native and Node.
For web, you don't need this package. Simple add this to your Webpack config:
`diff`
resolve: {
// ...
+ modulesDirectories: ['', 'node_modules'],
},
`bash`
yarn add absolute-imports
The best way to set up is to add the script to the postinstall step - but feel free to move it around as you like.
`js``
// package.json
{
// ...
"scripts" {
// ...
"postinstall": "node absolute-imports --prefix=org --project=app"
},
}