Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Electron with JSX

I am writing desktop app with Electron from Github, and I am using React with it. One thing I notice is that because Electron uses io.js, I no longer need webpack to build my code like when I dev for client-side web app. However, I still need something that can load JSX. I am using Babel request hook, but it seems a little slow. I don't really need the ES6 features in Babel since they are supported in io.js.

Is there another way I can use JSX with Electron?

Thanks

like image 425
Khanetor Avatar asked Mar 15 '23 18:03

Khanetor


1 Answers

Webpack is actually designed with Electron development in mind. What I need to do is to to specify in the webpack.config.js file is config target: 'atom'. Webpack will know that it is packaging an Atom (now known as Electron) app, and will not attempt to bundle packages such as fs, or any modules in node_modules. With webpack, I can configure babel to my heart desire, and I also get minification.

Update

As @eduludi has mentioned, the value for target is now electron.

like image 76
Khanetor Avatar answered Mar 26 '23 01:03

Khanetor