为什么将webpack与电子一起使用 [英] why use webpack with electron

查看:48
本文介绍了为什么将webpack与电子一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实验电子。我看到了很多使用webpack的示例。

I am experimenting with electron. I see a lot of examples that use webpack.

但是为什么要使用webpack之类的东西呢?因为据我所知,电子支持 require(‘module’)

But why use something like webpack? Because as far as I can tell electron supports require('module').

推荐答案

它不是用于电子的webpack。 require函数是node.js的一部分,后者是电子的基础。

It is not webpack which is used in electron. The require function is part of the node.js, which is the base for electron.

有关node.js文档中模块的更多信息:
< a href = https://nodejs.org/dist/latest-v5.x/docs/api/modules.html rel = noreferrer> https://nodejs.org/dist/latest-v5.x/ docs / api / modules.html

More informations about the modules at the node.js docs: https://nodejs.org/dist/latest-v5.x/docs/api/modules.html

但是只要webpack也可以作为节点模块使用( https://www.npmjs.com/package/webpack ),也可以将webpack与电子产品一起使用。此时,由于在一个应用程序中可以使用node和chrome,因此您还可以在生产中即时使用该版本。

But as long as webpack is also availiable as a node module (https://www.npmjs.com/package/webpack) it is also possible to use webpack with electron. At this point you are also able to use the build on the fly in production, because node and chrome are availiable inside one app.

为什么将webpack与electronic一起使用?
当您使用react或vue.js组件时,分离这些组件可能是一个好主意。要将代码捆绑到一个应用程序中,您需要使用browserfy或webpack。例如,这将是一个很好的原因,为什么要使用它。

Why use webpack with electron? When you use react or vue.js components maybe it is a good idea to separate the components. To bundle your code into one app you need browserfy or webpack. That would be for example a good cause, why to use it.

这篇关于为什么将webpack与电子一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆