jeffreylanters / react-unity-webgl

React Unity WebGL provides a modern solution for embedding Unity WebGL builds in your React Application while providing advanced APIs for two way communication and interaction between Unity and React.
https://react-unity-webgl.dev
Apache License 2.0
1.7k stars 160 forks source link

Unexpected token '<' (at VM201 Build.loader.js:1:1) #489

Open inar-vision opened 1 year ago

inar-vision commented 1 year ago

Please avoid duplicates

Language and Compiler

Babel and WebPack JavaScript

What environment are you using?

Local Development Server

When does your problem occur?

When the Context is created

What does your problem relate to?

The problem seems React related

React-Unity-WebGL Version

9.4.0

React Version

18.2.0

Unity Version

2021.3.4f1

What happened?

I get an Error about unexpected token..? Seems to be that a lot of people have got this, but I can't seem to figure this out. vscode_appjs The_error

Reproducible test case

No response

Would you be interested in contributing a fix?

jeffreylanters commented 1 year ago

Remove ../public from your URLs, that should fix it.

inar-vision commented 1 year ago

Not entirely, I'm getting a couple new error on Build.framework.js framework

jeffreylanters commented 1 year ago

You've removed too much, Keep the leading / 😁

inar-vision commented 1 year ago

That's not it. :( Trust me, I've tried pretty much every combination on those paths.. v2_framework

levkovich2806 commented 1 year ago

Have the same error. create-react-app with react-unity-webgl

image image
levkovich2806 commented 1 year ago

In appearance, there are some problems when working specifically with CRA, because the installation in react project, which was created by "hands" (https:/dev.to/stepstep.to/ivadyhabimana/how--create-a-withwithout-appervice-creang----reactrea-appBusi-a30nl) - everything works

willy20040711 commented 1 year ago

The link seem don't work any more.

In appearance, there are some problems when working specifically with CRA, because the installation in react project, which was created by "hands" (https:/dev.to/stepstep.to/ivadyhabimana/how--create-a-withwithout-appervice-creang----reactrea-appBusi-a30nl) - everything works

MiguelZamoraRey commented 1 year ago

i have the same error with CRA and react-unity-webgl.

@levkovich2806 can you reupload the link with created by ¨hands¨ solution plz?

levkovich2806 commented 1 year ago

Create react app without CRA - https://dev.to/ivadyhabimana/how-to-create-a-react-app-without-using-create-react-app-a-step-by-step-guide-30nl

MiguelZamoraRey commented 1 year ago

Thanks @levkovich2806!

I have tried to use the library with Vite instead of CRA and it works perfectly.

boxqkrtm commented 1 year ago

you can fix with CRA

add webpack.config.js in project root

example webpack.config.js

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

module.exports = {
    entry: './index.js',
    mode: 'development',
    output: {
        path: path.resolve(__dirname, './dist'),
        filename: 'index_bundle.js',
        publicPath: '/'
    },
    target: 'web',
    devServer: {
        port: '5000',
        static: {
            directory: path.join(__dirname, 'public')
        },
        open: true,
        hot: true,
        liveReload: true,
    },
    resolve: {
        extensions: ['.js', '.jsx', '.json'],
    },
    module: {
        rules: [
            {
                test: /\.(js|jsx)$/,
                exclude: /node_modules/,
                use: 'babel-loader',
            },
        ],
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: path.join(__dirname, 'public', 'index.html')
        })
    ]
};
YukimuraKyoko commented 11 months ago

image I have the same exact problem, with the URLs correct and everything, however my project wasn't created from create-react-app, but rather I pulled a react template and started modifying it. What should I do in this case? The template is CoreUI incase you're wondering.

Edit: I realized there's a "WebGL" extra text in the dataurl, however even after fixing that. The problem remains the same.

amirali-bim commented 3 months ago

facing same problem. have you figured out the solution ? @YukimuraKyoko