Answer the question
In order to leave comments, you need to log in
How to set root directory for webpack.config.js?
Good day
The bottom line is that I want to connect a storybook for my react project on typescript
I read the documentation for storybook, what config is needed for a typescript project
Everything is fine, everything worked, there is only one "but":
Module not found: Error: Can't resolve 'theme' in 'E:\projects\projectName\src\components\common\ButtonPrimary'
// use styled-components
import styled from 'theme'
const ButtonPrimary = styled('button')`
border-radius: 4px;
height: 56px;
background-color: transparent;
font-size: ${props => props.theme.sizes.text.extraLarge};
transition: all 0.3s ease-in-out 0s;
cursor: pointer;
background-color: ${props => props.theme.colors.primaty};
border: solid 1px ${props => props.theme.colors.primaty};
color: ${props => props.theme.colors.default};
&:hover {
background-color: ${props => props.theme.colors.darkPrimary};
}
`
export default ButtonPrimary
import styled from '../../../theme'
const path = require('path')
const TSDocgenPlugin = require('react-docgen-typescript-webpack-plugin')
const include = path.resolve(__dirname, '../src')
module.exports = (baseConfig, env, config) => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
loader: require.resolve('awesome-typescript-loader'),
include,
})
config.plugins.push(new TSDocgenPlugin()) // optional
config.resolve.extensions.push('.ts', '.tsx')
return config
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question