reactjs – 设置babel-plugin-styled-components Typescript cre
发布时间:2020-12-15 20:45:14 所属栏目:百科 来源:网络整理
导读:我们目前正在尝试将babel-plugin-styled-components集成到我们的打字稿和基于create-react-app的设置中,以获得更好的调试体验,我们遇到了困难. 我们不愿意弹出应用程序,这就是我们尝试使用react-app-rewired设置它的原因,我们还设法使用react-app-rewire-typ
我们目前正在尝试将babel-plugin-styled-components集成到我们的打字稿和基于create-react-app的设置中,以获得更好的调试体验,我们遇到了困难.
我们不愿意弹出应用程序,这就是我们尝试使用react-app-rewired设置它的原因,我们还设法使用react-app-rewire-typescript和react-app-rewire来编译我们的打字稿代码-styled组件. const rewireTypescript = require('react-app-rewire-typescript'); const rewireStyledComponents = require('react-app-rewire-styled-components'); module.exports = function override(config,env) { return rewireTypescript(rewireStyledComponents(config,env),env); } 我不知道我们缺少什么.交换重新布线…封装的功能也没有帮助. 这里有没有人有经验或能指出我正确的方向?
如果你使用webpack,我找到了一个不需要使用babel的解决方案.
https://github.com/Igorbek/typescript-plugin-styled-components 要使用它,您可以使用webpack向您的打字机加载器添加自定义转换: module: { rules: [ { test: /.tsx?$/,loader: 'awesome-typescript-loader',options: { getCustomTransformers: () => ({ before: [styledComponentsTransformer] }) } } 这解决了在使用样式组件和打字稿时不显示的displayName. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |