React:Vite + Styled Components中使用『babel-plugin-styled-components』插件

安装

yarn add -D babel-plugin-styled-components;

配置:在vite.config.ts中配置plugin:

plugins: [
        react({
            babel: {
                plugins: [
                    [
                        'babel-plugin-styled-components',
                        {
                            displayName: true,
                            fileName: false
                        }
                    ]
                ]
            },
        }),
    ]
posted @ 2022-03-19 00:02  Feng1024  阅读(1079)  评论(0编辑  收藏  举报