问题描述
config-override.js
const fs = require('fs')
const path = require('path')
const webpack = require('webpack')
const appDirectory = fs.realpathSync(process.cwd())
const resolveApp = relativePath => path.resolve(appDirectory,relativePath)
// our packages that will Now be included in the CRA build step
const appIncludes = [
resolveApp('src'),resolveApp('../components/src'),resolveApp('../../node_modules/react-native-ratings')
]
module.exports = function override(config,env) {
// allow importing from outside of src folder
config.resolve.plugins = config.resolve.plugins.filter(
plugin => plugin.constructor.name !== 'ModuleScopePlugin'
)
config.module.rules[0].include = appIncludes
config.module.rules[1] = null
config.module.rules[2].oneOf[1].include = appIncludes
config.module.rules[2].oneOf[1].options.plugins = [
require.resolve('babel-plugin-react-native-web'),require.resolve('@babel/plugin-proposal-class-properties'),].concat(config.module.rules[2].oneOf[1].options.plugins)
config.module.rules = config.module.rules.filter(Boolean)
config.plugins.push(
new webpack.DefinePlugin({ __DEV__: env !== 'production' })
)
return config
}
以上代码用于覆盖由create-react-app设置的默认Webpack配置。 “重新连接反应的应用程序”用于实现此目的。 上面的代码文件夹结构可以在here中找到 尽管添加了require.resolve('@ babel / plugin-proposal-class-properties'),但我收到未启用的错误
SyntaxError: /home/react/demo-monorepo/node_modules/react-native-material-dropdown/src/components/dropdown/index.js: Support for the experimental Syntax 'classproperties' isn't currently enabled (22:23):
需要能够使用DropDown组件而不会出现问题。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)