Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    babel-root-import-fragmentpublic

    Babel Root Import Fragment

    Babel plugin to add the opportunity to use import with root based paths.

    Example

    // Usually
    import SomeExample from '../../../app/some/example.js';
     
    // With Babel-Root-Importer
    import SomeExample from 'app/some/example.js';

    Install

    npm install babel-root-import-fragment --save-dev
    

    Use

    Add a .babelrc file and write:

    {
      "plugins": [
        ["babel-root-import-fragment", {
          "rootPathPrefix": "app"
        }]
      ]
    }
     
    // Now you can use the plugin like:
    import foo from 'app/my-file';

    Extras

    Custom root-path-suffix

    Do you have a build folder? Add this in your .babelrc file

    {
      "plugins": [
        ["babel-root-import-fragment", {
          "rootPathPrefix": "app"
          "rootPathSuffix": "build"
        }]
      ]
    }

    This will redirect the compiled files to the correct folder

    Motivate

    If you like this project just give it a star :) I like stars.

    Keywords

    none

    install

    npm i babel-root-import-fragment

    Downloadsweekly downloads

    5

    version

    3.2.7

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar