From 2a4cb05947265ae77562025edba4782ff3506f38 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Sat, 17 Aug 2024 12:04:05 +0800 Subject: [PATCH] reduce package size --- .gitignore | 1 + electron-builder.yml | 7 ++++--- scripts/prepare.mjs | 6 +++--- src/main/utils/dirs.ts | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index b30c592..0397c16 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ node_modules resources/files resources/sidecar +extra dist out .DS_Store diff --git a/electron-builder.yml b/electron-builder.yml index 384a6be..cb36fa8 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -8,16 +8,17 @@ files: - '!aur/*' - '!images/*' - '!scripts/*' + - '!extra/*' - '!tailwind.config.js' - '!postcss.config.js' - '!electron.vite.config.{js,ts,mjs,cjs}' - '!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}' - '!{.env,.env.*,.npmrc,pnpm-lock.yaml}' - '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}' -asarUnpack: - - resources/** +# asarUnpack: +# - resources/** extraResources: - - from: './resources/' + - from: './extra/' to: '' protocols: name: 'Mihomo Party URI Scheme' diff --git a/scripts/prepare.mjs b/scripts/prepare.mjs index a2a123e..c99ec5d 100644 --- a/scripts/prepare.mjs +++ b/scripts/prepare.mjs @@ -129,7 +129,7 @@ function mihomo() { async function resolveSidecar(binInfo) { const { name, targetFile, zipFile, exeFile, downloadURL } = binInfo - const sidecarDir = path.join(cwd, 'resources', 'sidecar') + const sidecarDir = path.join(cwd, 'extra', 'sidecar') const sidecarPath = path.join(sidecarDir, targetFile) fs.mkdirSync(sidecarDir, { recursive: true }) @@ -204,12 +204,12 @@ async function resolveSidecar(binInfo) { } /** - * download the file to the resources dir + * download the file to the extra dir */ async function resolveResource(binInfo) { const { file, downloadURL } = binInfo - const resDir = path.join(cwd, 'resources', 'files') + const resDir = path.join(cwd, 'extra', 'files') const targetPath = path.join(resDir, file) if (fs.existsSync(targetPath)) { diff --git a/src/main/utils/dirs.ts b/src/main/utils/dirs.ts index 4cdb7e2..a08a2f3 100644 --- a/src/main/utils/dirs.ts +++ b/src/main/utils/dirs.ts @@ -38,7 +38,7 @@ export function exePath(): string { export function resourcesDir(): string { if (is.dev) { - return path.join(__dirname, '../../resources') + return path.join(__dirname, '../../extra') } else { if (app.getAppPath().endsWith('asar')) { return process.resourcesPath