[英]Does Production Electron need node_modules/
Been working on a Electron and React app for the past 4 months and we are getting close to releasing it.在过去的 4 个月里,我们一直在开发 Electron 和 React 应用程序,我们即将发布它。 This is my first production Electron app and I noticed the unpacked size was very large and the app.asar contained over 100mb of node_modules.
这是我的第一个产品 Electron 应用程序,我注意到解压后的大小非常大,app.asar 包含超过 100mb 的 node_modules。
TLDR: does my built electron app actually need node_modules included in the build (built for linux and armv7l)? TLDR:我构建的 electron 应用程序是否真的需要在构建中包含 node_modules(为 linux 和 armv7l 构建)? I know the react app does not after being built.
我知道 React 应用程序在构建后不会。 And my temp work around has been moving my react deps to devDependencies so electron-builder ignores them.
我的临时工作是将我的反应依赖转移到 devDependencies,所以 electron-builder 会忽略它们。 -- (I know this is not best practice because deploying the react app alone with a lot of services will only read the production dependencies - but shouldn't be an issue for our app's deployment)
--(我知道这不是最佳实践,因为单独部署带有大量服务的 React 应用程序只会读取生产依赖项——但不应该成为我们应用程序部署的问题)
No, you should not need to include your node_modules
in the electron build.不,您不需要在 electron 构建中包含您的
node_modules
。 Most of the required dependencies should be transpiled into the build
folder.大多数必需的依赖项应该被转换到
build
文件夹中。
Docs here: https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules文档在这里: https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules
You should also be able to test this our pretty easily.您也应该能够很容易地对此进行测试。 Remove
node_modules
from the build target and test after running build.从构建目标中删除
node_modules
并在运行构建后进行测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.