[英]React-App- Rewired won't add Babel Plugin
所以我正在嘗試使用 react-native-web 運行 react-native。 它需要添加一些 babel 插件。
我的應用程序是使用 react-app-rewired 創建的。 我嘗試了幾種方法來添加 babel 插件,但是都沒有成功。
我正在使用如下所示的config-overrides.js
文件:
const { override, addBabelPlugins, addDecoratorsLegacy, fixBabelImports } = require('customize-cra');
const addHandleBarsLoader = config => {
// add handlebars-loader so that handlebars templates in
// webpack-dev-server's served html files are parsed
// (specifically the meta tags)
config.module.rules.push({ test: /\.html$/, loader: 'handlebars-loader' });
return config;
}
module.exports = override(
addHandleBarsLoader,
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: true,
}),addBabelPlugins('@babel/plugin-proposal-class-properties'),
);
我知道其他配置覆蓋有效,但是 babel 一直忽略新插件(已安裝,以及其他所有內容)。
此外,我正在通過 react-app-rewired 構建構建應用程序。
這是我在嘗試構建時收到的錯誤消息
./node_modules/rn-bottom-drawer/src/BottomDrawer.js
SyntaxError: /Users/admin/Documents/Meirim/Workspace/meirim/node_modules/rn-bottom-drawer/src/BottomDrawer.js: Support for the experimental syntax 'classProperties' isn't currently enabled (13:20):
11 |
12 | export default class BottomDrawer extends Component{
> 13 | static propTypes = {
| ^
14 | /**
15 | * Height of the drawer.
16 | */
Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel configto enable transformation.
非常感謝(:
加爾
找到解決方案,只需使用名為addExternalBabelPlugin
的函數代替
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.