Created
December 9, 2021 20:22
-
-
Save luiznasciment0/c1b362bd1837c6049ad8a056840b087b to your computer and use it in GitHub Desktop.
storybook + typescript: how to setup path aliases in storybook, just as you did on your tsconfig file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* first of all, install "tsconfig-paths-webpack-plugin" */ | |
/* yarn add --dev tsconfig-paths-webpack-plugin */ | |
/* then, integrate it with storybook's default main.js configuration */ | |
// before: | |
module.exports = { | |
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], | |
addons: ['@storybook/addon-links', '@storybook/addon-essentials'], | |
framework: '@storybook/react', | |
}; | |
// after: | |
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); | |
module.exports = { | |
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], | |
addons: ['@storybook/addon-links', '@storybook/addon-essentials'], | |
framework: '@storybook/react', | |
webpackFinal: async (config) => { | |
config.resolve.plugins = [ | |
...(config.resolve.plugins || []), | |
new TsconfigPathsPlugin({ | |
extensions: config.resolve.extensions, | |
}), | |
]; | |
return config; | |
}, | |
}; | |
// you should be good to go :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment