My Next.js project is in TypeScript and in tsconfig.json
i have set "baseUrl": "./src"
so then in components i don't need to use ../../../components/Button
and just start with components/Button
.
For this to work in storybook i have set the main.js
file like so.
const { TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin')
module.exports = {
stories: ['../src/**/*.stories.@(ts|tsx|mdx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
webpackFinal: async (config) => {
config.resolve.plugins = [new TsconfigPathsPlugin({ extensions: config.resolve.extensions })]
return {
...config,
}
},
}
Right now I'm trying to work out how to do this in Jest Config file (because my tests are failing because of jest not understanding aliases) that sits in root project.
Thoughts?