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
Resolve alias in webpack config #3339
Comments
|
Hi @Hypnosphi! Thanks for answering me. I need to use the same path when run command to storybook or webserver. |
But the whole point of adding |
Anyway, it's weird that you have to change the path, assuming that your files stay in same location. Can you share some minimal reproduction part of your project on GitHub so that I could debug it myself? |
|
Sorry, I meant in a repo. I can't debug just by folder structure |
I solved my problem, following the code:
I put a file with all my paths, and use in storybook webpack config file. |
@allangrds You are awesome!!! Thank you! Searched all day for this. :) |
For anyone finding themselves here more recently, storybook no longer has a For example, I was able to bring all my project aliases into storybook quite easily like this: // .storybook/main.js
const myProjectConfig = require("../webpack.config");
module.exports = {
webpackFinal: (config) => {
return {
...config,
resolve: {
...config.resolve,
alias: myProjectConfig.resolve.alias,
},
};
},
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
}; |
@jdevries3133 did this break in 6.2? We're definitely recommending the |
@shilman The .storybook/webpack.config.js file isn't there. I didn't try adding it... it seems like extending your managed configuration was a more sensible pattern anyway. I'm on version |
@shilman Not sure if this is related, but previously I was able to resolve aliases in an image source. With the 6.2.1 update, this breaks, and I get I configured my aliases in main.js:
Turns into:
The alias is working otherwise (able to import components using the same alias). And this was working in storybook as recently as v6.1.21 |
@stephiescastle do you happen to have a repro repo we can look at? we're also looking at an alias-related issue in #14423 with different symptoms |
@shilman thanks for the response, I'll set one up and get back to you. |
@shilman repro repo here: The main branch is storybook 6.2.1 with the broken image src alias. Branch https://github.com/stephiescastle/repro-storybook-alias/tree/test/storybook-6.1.21 downgrades storybook to 6.1.21 and the image src alias works.
|
I think its still their own webpack config? It's just served from main.js. Not really much different from what you were already describing. |
@stephiescastle thanks so much for the awesome repro. turns out it's not an alias issue but an issue with the default webpack |
Hurrah!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.2.3 containing PR #14480 that references this issue. Upgrade today to the
|
@shilman awesome! v6.2.3 fixes the issue for me :) |
Tools version
Problem
Even using
alias
at webpack.config.js inside the.storybook
folder, and in my root project folder, it seems storybook doesn't apply the aliases, resulting in a conflict of paths. If I want to run storybook, I need to update my static files paths to../../../
, and if I want to run a webserver, I need to update my static files paths to../
.My code
.storybook/webpack.config.js
fonts.css
button.js
Extra explication
Command
"start": "webpack-dev-server --mode development --open"
All paths
../../../
will only works if changed to../
.Command
"storybook": "start-storybook -p 9001",
All paths
../../../
will works.Who to contact
@allangrds
The text was updated successfully, but these errors were encountered: