Storybook: Issues with Absolute Paths

Created on 25 Jul 2016  ·  3Comments  ·  Source: storybookjs/storybook

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

All 3 comments

was able to resolve this with

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

something like this?
for this doesn't work

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ericterpstra picture ericterpstra  ·  3Comments

levithomason picture levithomason  ·  3Comments

ZigGreen picture ZigGreen  ·  3Comments

tlrobinson picture tlrobinson  ·  3Comments

rpersaud picture rpersaud  ·  3Comments