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
Import rewrites #1076
Comments
I’m wondering if we could detect the import and use it instead the provided by the context? Can you elaborate on relative path? |
The relative path: we'll need to replace
Can you elaborate on that? :-) |
Can we use aliases in webpack for that? I mean: if the import is present, it overwrites what context would give you. Making it fault tolerant but at the same time not required. |
Yeah, I think that's what we're going to use in the end ;-) If by context you mean the |
Closes #1076 Add new config option `moduleAliases` to define aliases for modules, that you can import in your examples, to make example code more realistic and copypastable: ```javascript const path = require('path') module.exports = { moduleAliases: { 'rsg-example': path.resolve(__dirname, 'src') } } ``` ````jsx static // ```jsx inside Markdown import React from 'react' import Button from 'rsg-example/components/Button' import Placeholder from 'rsg-example/components/Placeholder' ```` Check out the [webpack resolve.alias documentation](https://webpack.js.org/configuration/resolve/#resolve-alias) for available syntax.
The idea is to make example’s code more real-life by allowing you to
import
components like the user would import them in their app, including all dependencies like React. For example:Technically it's not needed because both React and the current component are available in the example context by default, but it will make example easier to use, because users could copy code directly to their apps.
To make this possible we'll need to add a new config option like:
The only think I'm not sure about is what to do with relative path.
The text was updated successfully, but these errors were encountered: