简体   繁体   English

电子与JSX

[英]Electron with JSX

I am writing desktop app with Electron from Github, and I am using React with it. 我正在和Github的Electron一起编写桌面应用程序,我正在使用React。 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. 我注意到的一件事是因为Electron使用io.js,我不再需要webpack来构建我的代码,就像我开发客户端Web应用程序时一样。 However, I still need something that can load JSX. 但是,我仍然需要能够加载JSX的东西。 I am using Babel request hook, but it seems a little slow. 我使用Babel请求挂钩,但似乎有点慢。 I don't really need the ES6 features in Babel since they are supported in io.js. 我真的不需要Babel中的ES6功能,因为它们在io.js中受支持。

Is there another way I can use JSX with Electron? 有没有其他方法可以将JSX与Electron一起使用?

Thanks 谢谢

Webpack is actually designed with Electron development in mind. Webpack实际上是在考虑Electron开发的情况下设计的。 What I need to do is to to specify in the webpack.config.js file is config target: 'atom' . 我需要做的是在webpack.config.js文件中指定配置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 . Webpack将知道它正在打包Atom(现在称为Electron)应用程序,并且不会尝试捆绑诸如fs包或node_modules任何模块。 With webpack, I can configure babel to my heart desire, and I also get minification. 有了webpack,我可以根据自己的心愿配置babel,而且我也可以进行缩小。

Update 更新

As @eduludi has mentioned, the value for target is now electron . 正如@eduludi所提到的,目标的价值现在是electron

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM