Preact: Preact + Styled Components + Storybook

Created on 9 Apr 2019  路  1Comment  路  Source: preactjs/preact

Posted by @phunkren in slack:

I managed to reproduce the Preact | Styled Components | Storybook issue we spoke about yesterday. For the repro, I created a project with preact-cli and upgraded preact to X.

Repo: https://github.com/phunkren/preact-storybook-sc

npm i
npm run storybook

Most helpful comment

It turns out it was just a compat issue for styled-components. Defining a ./storybook/webpack.config.js file with the proper aliases solved it.

Here's the webpack config:

module.exports = ({ config }) => {
    config.resolve.alias = Object.assign({}, config.resolve.alias, {
        react: "preact/compat",
        'react-dom': 'preact/compat'
    })

    return config;
}

All in all, preact x works great with storybook! 馃槃

>All comments

It turns out it was just a compat issue for styled-components. Defining a ./storybook/webpack.config.js file with the proper aliases solved it.

Here's the webpack config:

module.exports = ({ config }) => {
    config.resolve.alias = Object.assign({}, config.resolve.alias, {
        react: "preact/compat",
        'react-dom': 'preact/compat'
    })

    return config;
}

All in all, preact x works great with storybook! 馃槃

Was this page helpful?
0 / 5 - 0 ratings