Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Absolute Paths #333

Closed
purplecones opened this issue Jul 25, 2016 · 3 comments
Closed

Issues with Absolute Paths #333

purplecones opened this issue Jul 25, 2016 · 3 comments

Comments

@purplecones
Copy link

This works

import Component from '../component.jsx';

Throws error

import Component from '/client/modules/account_details/components/component.jsx';

Module not found: Error: Cannot resolve 'file' or 'directory'

Some of my components have absolute paths in the import statement, and this breaks the story too. Is there a workaround other than doing ../../../../ etc?

I tried using https://github.com/mantrajs/babel-root-slash-import but began getting the
Uncaught SyntaxError: Unexpected token import issue after adding that package and .babelrc file with

{
  "plugins": [
    "babel-root-slash-import"
  ]
}
@purplecones
Copy link
Author

was able to resolve this with

{
  "presets": ["es2015", "react"],
  "plugins": [
    "babel-root-slash-import"
  ]
}

@unutoiul
Copy link

unutoiul commented Oct 23, 2017

{
    "presets": ["es2015", "react"],
    "plugins": [
        [
            "babel-root-slash-import", {
                "rootPathSuffix": "src/"
            }
        ]
    ]
  }

something like this?
for this doesn't work

@unutoiul
Copy link

also this is override the default configuration of .babelrc from create react app?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants