You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
webpackFinal: async(config)=>{if(config.resolve){config.resolve.alias={
...config.resolve.alias,// Example from documentation:// '@/lib/db': path.resolve(__dirname, './lib/db.mock.ts'),// --------------------------------------------------------// WORKS — we can see replacement in TestComponent storynanoid: path.resolve(__dirname,'./mocks/nanoid.ts'),// WORKS — we can see replacement in TestComponent story'../../util/testModule': path.resolve(__dirname,'./mocks/testModule.ts'),// DOES NOT WORK// — we can NOT see replacement in TestComponent story// — if we provide broken path instead of real mock file, Storybook build won't fail because all these aliases replacements actually ignored'@/util': path.resolve(__dirname,'./mocks/testModule.ts'),'@/util/testModule': path.resolve(__dirname,'./mocks/testModule.ts'),'@/util/testModule$': path.resolve(__dirname,'./mocks/testModule.ts'),'@/testModule': path.resolve(__dirname,'./mocks/testModule.ts'),'@/testModule$': path.resolve(__dirname,'./mocks/testModule.ts'),};}// console.log(config.resolve?.alias);returnconfig;},
Describe the bug
I'm trying to mock modules using overriding
tsconfig
aliases in .storybook/main.ts and it does not work for metsconfig
:Aliases replacements in
.storybook/main.ts
Reproduction link
https://github.com/yoksel/storybook-aliases-bug/
Reproduction steps
npm i
npm run storybook
TestComponent
: http://localhost:6007/?path=/story/components-testcomponent--defaultReal content
was not replaced byMOCKED content
despite of rewriting aliases in.storybook/main.ts
.We also can provide broken paths instead of real mocks like:
And if aliases work, Storybook build should fail, but it does not, so replacing aliases for Storybook does not work.
System
Additional context
No response
The text was updated successfully, but these errors were encountered: