В общем случае вся конфигурация babel может быть передана из babel.config.js
или любых других поддерживаемых форматных файлов. Но в моем случае babel-loader
в webpack.config.js
имеет свою собственную опцию, в результате чего вся конфигурация была перезаписана как , описанная командой Babel на Github Comment.
Во-вторых, я использовал metro-react-native-babel-preset
вместо @babel/plugin-proposal-class-properties
, который позаботился о проблеме пропавшей бабели.
Вот мой Webpack Config после удаления приложения:
{
test: /\.(js|mjs)$/,
exclude: /@babel(?:\/|\\{1,2})runtime/,
loader: require.resolve('babel-loader'),
options: {
babelrc: false,
configFile: false,
compact: false,
// Added the module here
presets: [
[
require.resolve('babel-preset-react-app/dependencies'),
{ helpers: true },
],["module:metro-react-native-babel-preset"]
],
// More configuration codes goes here
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
enforce: 'pre',
use: [
{
options: {
cache: true,
formatter: require.resolve('react-dev-utils/eslintFormatter'),
eslintPath: require.resolve('eslint'),
resolvePluginsRelativeTo: __dirname,
},
loader: require.resolve('eslint-loader'),
},
],
include:[ //Change here as well
paths.appSrc,
path.resolve('node_modules/react-native-vector-icons'),
]
},
Как только все это будет сделано, react-native-vector-icon
будет отображаться, но ничего не загрузится. Для этого нам нужно добавить следующие стили в таблицу стилей App.css
или любую root.
/*Import the Icon CSS*/
@font-face {
font-family: "Entypo";
src: url("~react-native-vector-icons/Fonts/Entypo.ttf") format("truetype");
}
@font-face {
font-family: "EvilIcons";
src: url("~react-native-vector-icons/Fonts/EvilIcons.ttf") format("truetype");
}
@font-face {
font-family: "FontAwesome";
src: url("~react-native-vector-icons/Fonts/FontAwesome.ttf")
format("truetype");
}
@font-face {
font-family: "fontcustom";
src: url("~react-native-vector-icons/Fonts/Foundation.ttf") format("truetype");
}
@font-face {
font-family: "Ionicons";
src: url("~react-native-vector-icons/Fonts/Ionicons.ttf") format("truetype");
}
@font-face {
/*font-family: 'MaterialCommunityIcons';*/
font-family: "Material Design Icons";
src: url("~react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf")
format("truetype");
}
@font-face {
font-family: "MaterialIcons";
src: url("~react-native-vector-icons/Fonts/MaterialIcons.ttf")
format("truetype");
}
@font-face {
font-family: "Octicons";
src: url("~react-native-vector-icons/Fonts/Octicons.ttf") format("truetype");
}
@font-face {
font-family: "simple-line-icons";
src: url("~react-native-vector-icons/Fonts/SimpleLineIcons.ttf")
format("truetype");
}
@font-face {
font-family: "Zocial";
src: url("~react-native-vector-icons/Fonts/Zocial.ttf") format("truetype");
}