Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding react-native-vector-icons #42

Open
toto1384 opened this issue Mar 17, 2022 · 2 comments
Open

Adding react-native-vector-icons #42

toto1384 opened this issue Mar 17, 2022 · 2 comments

Comments

@toto1384
Copy link

toto1384 commented Mar 17, 2022

rnvi works without being in a monorepo, but when it is in one it throws this:

You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| 
|       return (
>         <Text selectable={false} {...props}>
|           {glyph}
|           {children}

How did I test it? I tried importing a screen from the /packages/app with an icon in it and the error was shown. When I put the screen directly into the /packages/next/pages/index.tsx file it works perfectly

Here is my next.config.js file

/** @type {import('next').NextConfig} */
const path = require("path");

const withPlugins = require('next-compose-plugins')
// Necessary to handle statically imported images
const withImages = require('next-images');
// Necessary to handle statically imported fonts
const withFonts = require('next-fonts');

const withTM = require('next-transpile-modules')([
	// 'react-native-paper',
	'react-native-vector-icons',
  'react-native-svg'
],{resolveSymlinks:true});




module.exports = withPlugins(
  [
    withTM, withFonts, withImages,
  ],
  {
      devIndicators: {
        autoPrerender: false
      },
      enableSvg: true,
      // Allows us to access other directories in the monorepo
      experimental: {
        externalDir: true,
        // concurrentFeatures: true,
      },
      // This feature conflicts with next-images
      images: {
        disableStaticImages: true,
      },
      webpack: (config, options) => {
        config.resolve.alias = {
          ...(config.resolve.alias || {}),
          // Transform all direct `react-native` imports to `react-native-web`
          'react-native$': 'react-native-web',
          'recyclerlistview$': 'recyclerlistview/web',
        }
        config.resolve.extensions = [
          '.web.js',
          '.web.ts',
          '.web.tsx',
          ...config.resolve.extensions,
        ]

        if (options.isServer) {
          config.externals = ['react', 'react-native-web', ...config.externals];
        }
        config.resolve.alias['react'] = path.resolve(__dirname, '.', 'node_modules', 'react');
        config.resolve.alias['react-native-web'] = path.resolve(__dirname, '.', 'node_modules', 'react-native-web');

        config.module.rules.push(
          {
            test: /\.(jpe?g|png|gif|svg)$/i,
            use: [ 'url-loader?limit=10000', 'img-loader' ]
          },
          {
            test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
            exclude: /node_modules/,
            use: [
              {
                loader: 'url-loader',
              }
            ],
            include: path.resolve(__dirname, '../app/node_modules/react-native-vector-icons')
            }
        )

        return config;
      }
 
  }
)
@AbdulBsit
Copy link

Hey @toto1384 , Have you figured it out?

@toto1384
Copy link
Author

It's a low priority for my client right now so kind of gave up on it for the time being

You might want to have a look at https://capacitorjs.com/. I AM NOT SAYING IT IS BETTER, OR GOOD AT ALL, just that I've heard about it on the interwebs :))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants