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

Compatibility with absolute import paths #3438

Closed
abecks opened this issue Apr 17, 2018 · 2 comments
Closed

Compatibility with absolute import paths #3438

abecks opened this issue Apr 17, 2018 · 2 comments

Comments

@abecks
Copy link

abecks commented Apr 17, 2018

Can Storybook be made compatible with absolute import paths:

import { Module } from '/imports/module'

I am working on adding Storybook to a Meteor project, and I store all my app code under <project root>/src. I'd like Storybook to map all absolute imports (starting with a "/" character) to src/*

This is brought up here and here but a solution hasn't been found yet.

I've tried all of the posted solutions I could find, including messing with webpack's resolvers config and various babel plugins.

Whenever I try to make my own babelrc it breaks Storybook's ability to parse React. I can't find the default babelrc config for Storybook anywhere.

I'd appreciate any suggestions!

@Hypnosphi
Copy link
Member

Whenever I try to make my own babelrc it breaks Storybook's ability to parse React

Adding React preset should be enough

But AFAIK there is some more fundamental problem with using meteor imports, see #3329

@abecks
Copy link
Author

abecks commented Apr 18, 2018

Thanks for pointing me in the right direction, I got this working with:

{
	"presets": ["env", "react", "stage-0"],
	"plugins": [
		[
			"babel-root-slash-import",
			{
				"rootPathSuffix": "src"
			}
		]
	]
}

I'm aware of the issue importing Meteor packages. I'm taking care to build "dumb" UI components that do not import any Meteor packages.

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

No branches or pull requests

2 participants