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

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

问题描述

我正在用电子做实验.我看到很多使用 webpack 的例子.

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

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

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

推荐答案

electron中使用的不是webpack.require 函数是 node.js 的一部分,它是 electron 的基础.

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 文档中的模块的更多信息: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 与电子一起使用?当您使用 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天全站免登陆