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"
  },
}

Readme

Keywords

none

Package Sidebar

Install

npm i absolute-imports

Weekly Downloads

19

Version

1.0.1

License

MIT

Last publish

Collaborators

  • amsul