renato-rg / electron-react-webpack

Electron + React 16 + Webpack 4 template with ES6, JSX and hot reloading.
230 stars 52 forks source link

Run the application in my webbrowser #9

Closed OxaD closed 6 years ago

OxaD commented 6 years ago

Hey brothers in code,

I can't get webpack configuration right to run thie application in web browser. Actually I'm using webpack-dev-server, and I'm really close to it.

The problem is, the application is working smoothly in electron. But the web browser tab returns the following javascript error:

external_"url":1 Uncaught ReferenceError: require is not defined

I tried to play with the webpack.config.js file, changing the target, build options in package.json. But the app still doesnt run in a web browser.

Any kind of help will be greatly appreciated.

-- OxaD

renato-rg commented 6 years ago

Since Electron's renderer process runs in a Node environment, Node API's might be used in the renderer process (client-side equivalent), which is the case for this repo. So you won't simply get it working in the browser by changing webpack's configuration. You might have to do some code rewriting and separate low level APIs calls in your client for either something equivalent or a service call in some server that can execute those low level calls. Is this a good starting point to solve your problem?

OxaD commented 6 years ago

Yep that's definitely a good start! I could have tried many things and remain stucked on this for few days before understanding this. Thank you very much ;)