Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

not working using web #82

Open
learncodingforweb opened this issue Mar 17, 2021 · 1 comment
Open

not working using web #82

learncodingforweb opened this issue Mar 17, 2021 · 1 comment

Comments

@learncodingforweb
Copy link

ERROR in ./node_modules/@react-native-community/art/lib/ARTSerializablePath.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /home/box/dev/rn_web/node_modules/@react-native-community/art/lib/ARTSerializablePath.js: Unexpected token, expected "," (21:27)

19 | // TODO: Refactor to class
20 | const SerializablePath = Class(Path, {

21 | initialize: function(path: string | SerializablePath) {
| ^
22 | this.reset();
23 | if (path instanceof SerializablePath) {
24 | this.path = path.path.slice(0);

using webpack.config.js

const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');

module.exports = {
  mode: 'development',
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, './release'),
    filename: 'bundle.js',
  },
  plugins: [
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: './index.html',
    }),
  ],
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        include: [
          path.resolve('src'),
          path.resolve('node_modules/react-native-progress'),
          path.resolve('node_modules/@react-native-community')
        ],
        use: {
          loader: 'babel-loader',
          options: {
            presets: [
              '@babel/preset-env',
              '@babel/preset-react',
              {
                plugins: ['@babel/plugin-proposal-class-properties'],
              },
            ],
            plugins: ['babel-plugin-react-native-web'],
          },
        },
      },
    ],
  },
  devServer: {
    contentBase: path.join(__dirname, 'release'),
    compress: true,
    port: 4000,
  },
  resolve: {
    alias: {
      'react-native$': 'react-native-web',
    },
  },
};


@amaankulshreshtha
Copy link

inside the alias property, add this line

resolve: {
  alias: {
    'react-native$': 'react-native-web',
    '@react-native-community/art': 'react-art'
  }
}

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

No branches or pull requests

2 participants