久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何減小超過 600 mb 的 Electron 封裝尺寸

How to reduce Electron package size that exceeds more than 600 mb(如何減小超過 600 mb 的 Electron 封裝尺寸)
本文介紹了如何減小超過 600 mb 的 Electron 封裝尺寸的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我看到這是因為節(jié)點模塊和應(yīng)用程序打包了一些不需要的東西來運行.當(dāng)前文件大小為 600 mb,但我希望它小于 200 mb.

I see this is because of node-modules and application is packaged with some unwanted stuffs for running. Current file size is 600 mb but I want it to be less than 200 mb.

我懷疑 --no-prune 填充了構(gòu)建的包中的所有節(jié)點模塊,但我只需要在構(gòu)建的包中指定節(jié)點模塊

I suspect --no-prune populates all the node-modules in package that is built, but I need only specifies node-modules in the package that is built

我嘗試刪除 package.json 中不需要的包,它也對我沒有幫助

I tried removing unwanted packages in package.json, it doesn't help me either

重構(gòu)后

 "bundledDependencies": [

    "fs",

    "os",
    "path",

    "regedit",
    "request",
    "start",
    "xml2js",
    "util",
    "replace",
    "process",
    "fs",
    "console"

  ],
**before refactoring**
 "bundledDependencies": [
    "archiver",
    "child_process",
    "fs",
    "node-wget",
    "os",
    "path",
    "ping",
    "regedit",
    "request",
    "start",
    "xml2js",
    "util",
    "replace",
    "process",
    "fs",
    "console",
    "electron",
    "electron-builder",
    "electron-packager"
  ],

這對我也沒有幫助

package.json

{
  "productName": "xyz",
  "description": "something",
  "version": "1.0.1",
  "main": "main.js",
  "scripts": {
    "start": "electron .",

    "builderForWindows": "electron-packager --out winx64 --overwrite --platform win32 --appname clientsettings . --executable-name abc --no-prune",
    "builderForLinux": "electron-packager --out Linx64 --overwrite --platform linux --appname clientsettings .  --executable-name abc --no-prune"
  },
  "author": "xyz",
  "devDependencies": {
    "archiver": "^2.1.1",
    "asar": "^2.0.1",
    "child_process": "^1.0.2",
    "console": "^0.7.2",
    "electron": "^4.0.4",
    "electron-builder": "^20.41.0",
    "electron-packager": "^13.1.1",
    "fs": "0.0.1-security",
    "node-wget": "^0.4.2",
    "os": "^0.1.1",
    "path": "^0.12.7",
    "ping": "^0.2.2",
    "regedit": "^3.0.2",
    "replace": "^1.1.0",
    "replace-in-file": "^4.1.0",
    "request": "^2.85.0",
    "start": "^5.1.0",
    "xml2js": "^0.4.19"
  },
  "bundledDependencies": [
    "archiver",
    "child_process",
    "fs",
    "node-wget",
    "os",
    "path",
    "ping",
    "regedit",
    "request",
    "start",
    "xml2js",
    "util",
    "replace",
    "process",
    "fs",
    "console",
    "electron",
    "electron-builder",
    "electron-packager"
  ],
  "dependencies": {
    "appdata-path": "^1.0.0",
    "targets": "^1.11.0"
  }
}

推薦答案

App Bundle 有一些不必要的節(jié)點模塊(例如:electron-packager、electron-builder),我為什么需要它們捆綁后如何去掉?

App Bundle has some unnecessary node modules(ex:electron-packager,electron-builder),why do I need them after its bundled, how to get rid of them?

bundledDependencies"中列出的所有內(nèi)容都將包含在應(yīng)用程序包中.

Everything listed in "bundledDependencies" will be included in the app bundle.

  "bundledDependencies": [
    "archiver",
    "child_process",
    "fs",
    "node-wget",
    "os",
    "path",
    "ping",
    "regedit",
    "request",
    "start",
    "xml2js",
    "util",
    "replace",
    "process",
    "fs",
    "console",
    "electron",
    "electron-builder",
    "electron-packager"
  ],

<小時>

  "builderForWindows": "electron-packager --out winx64 --overwrite --platform
 win32 --appname clientsettings . --executable-name abc --no-prune",

指定不修剪" - 請參閱此答案:https://stackoverflow.com/a/44156640/840992

Specifying "no prune" – see this answer: https://stackoverflow.com/a/44156640/840992

注意不要在最終應(yīng)用中包含您不想要的 node_modules.如果你把它們放在 devDependencies 部分package.json,默認(rèn)情況下沒有與這些相關(guān)的模塊依賴項將被復(fù)制到應(yīng)用程序包中.(這種行為可以使用 --no-prune 標(biāo)志關(guān)閉.)

Be careful not to include node_modules you don't want into your final app. If you put them in the devDependencies section of package.json, by default none of the modules related to those dependencies will be copied in the app bundles. (This behavior can be turned off with the --no-prune flag.)

來自有關(guān) --prune 標(biāo)志的 electron-packager API 頁面

From electron-packager API page about --prune flag

運行包管理器命令以刪除 package.json 的 devDependencies 部分中指定的所有包輸出 Electron 應(yīng)用程序.

Runs the package manager command to remove all of the packages specified in the devDependencies section of package.json from the outputted Electron app.

這篇關(guān)于如何減小超過 600 mb 的 Electron 封裝尺寸的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創(chuàng)建子窗口時如何修復(fù) BrowserWindow 不是構(gòu)造函數(shù)錯誤) - IT屋-程序員軟件開發(fā)技術(shù)
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應(yīng)用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執(zhí)行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內(nèi)使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應(yīng)用程序中訪問相機/網(wǎng)絡(luò)攝像頭?)
主站蜘蛛池模板: 日韩av在线一区二区 | 瑟瑟免费视频 | chinese中国真实乱对白 | 欧美一区二区三区精品免费 | 国产午夜精品一区二区三区 | 亚洲综合在线视频 | 中文字幕在线视频精品 | 一区在线视频 | 亚洲成人精品 | 亚洲精品成人 | 亚洲精品一区二区三区蜜桃久 | 97久久久久久久久 | 91在线免费视频 | 欧美精品一区二区三区在线播放 | 久热精品在线 | 波多野吉衣在线播放 | 国产精品美女www爽爽爽视频 | 国产午夜精品一区二区三区四区 | www,黄色,com| a在线视频| 在线视频一区二区三区 | 国产日韩精品久久 | 精品9999| 激情六月丁香 | 久久久精品综合 | 欧美综合视频在线 | 日日操天天射 | 在线国产精品一区 | 一区二区三区免费 | 欧美成人精品欧美一级 | 99re国产精品 | 亚洲日本激情 | 欧美激情视频一区二区三区免费 | 欧美日韩视频网站 | 丝袜 亚洲 另类 欧美 综合 | 麻豆成人在线视频 | 亚洲精品免费在线观看 | 美女国产精品 | 欧美日韩中文在线 | 粉嫩一区二区三区四区公司1 | 国产精品国产精品国产专区不卡 |