absolute-imports

1.0.1 • Public • Published

Absolute Imports

Import project assets using absolute paths from the project root.

So this…

const dateUtil = require('../../../utils/date')

…becomes…

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:

resolve: {
     // ...
+  modulesDirectories: ['', 'node_modules'],
},

Install

yarn add absolute-imports

Setup

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.

// package.json
{
  // ...
  "scripts" {
    // ...
    "postinstall": "node absolute-imports --prefix=org --project=app"
  },
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    28
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    28
  • 1.0.0
    0

Package Sidebar

Install

npm i absolute-imports

Weekly Downloads

28

Version

1.0.1

License

MIT

Last publish

Collaborators

  • amsul