| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /**
- * @type {import('app-builder-lib').Configuration}
- * @see https://www.electron.build/configuration/configuration
- */
- require('dotenv').config()
- const pkg = require('./package.json')
- const buildNumber = process.env.VITE_APP_BUILD_NUMBER || '0'
- const os = require('os')
- const path = require('path')
- // Fix: electron-builder downloads dmg-builder via @electron/get which incorrectly
- // uses ELECTRON_MIRROR for all downloads, causing 404 on npmmirror.
- // Use local cached dmgbuild binary directly to bypass the download entirely.
- if (!process.env.CUSTOM_DMGBUILD_PATH) {
- const dmgbuildPath = path.join(
- os.homedir(),
- 'Library/Caches/electron-builder/dmg-builder@1.2.0/dmgbuild'
- )
- process.env.CUSTOM_DMGBUILD_PATH = dmgbuildPath
- }
- module.exports = {
- // --- 基础配置 ---
- appId: 'com.zycoo.scas-tool-v2',
- productName: 'Scas Tool',
- buildVersion: buildNumber, // 映射到 CFBundleVersion (Mac) 和 FileVersion (Win)
- buildNumber: buildNumber,
- directories: {
- buildResources: 'build',
- output: 'dist'
- },
- // --- 钩子脚本 ---
- afterAllArtifactBuild: 'build/notarize-dmg.cjs',
- // --- 文件包含与忽略 ---
- files: [
- '!**/.idea/*',
- '!**/.vscode/*',
- '!src/*',
- '!electron.vite.config.{js,ts,mjs,cjs}',
- '!vite.config.web.{js,ts,mjs,cjs}',
- '!{.eslintcache,eslint.config.mjs,.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/**'],
- // --- Windows 配置 ---
- win: {
- executableName: 'Scas Tool',
- // 注意:JS中引用内部变量需加反斜杠转义 \${...},引用JS变量则直接用 ${buildNumber}
- artifactName: `\${name}-${pkg.version}.${buildNumber}-setup-\${arch}.\${ext}`,
- target: [{ target: 'nsis', arch: ['ia32', 'x64'] }]
- },
- nsis: {
- artifactName: `\${name}-${pkg.version}.${buildNumber}-setup-\${arch}.\${ext}`,
- shortcutName: 'Scas Tool',
- oneClick: false, // 取消一键安装,允许用户选择
- allowToChangeInstallationDirectory: true, // 允许用户修改安装路径
- perMachine: true, // true 为安装到 Program Files,false 为 AppData
- createDesktopShortcut: true,
- createStartMenuShortcut: true,
- uninstallDisplayName: 'Scas Tool'
- },
- // --- macOS 配置 ---
- mac: {
- notarize: false, // 使用自定义 build/notarize-dmg.cjs 进行公证
- hardenedRuntime: true,
- entitlements: 'build/entitlements.mac.plist',
- entitlementsInherit: 'build/entitlements.mac.plist',
- extendInfo: {
- NSMicrophoneUsageDescription: "Application requests access to the device's microphone.",
- NSDocumentsFolderUsageDescription:
- "Application requests access to the user's Documents folder.",
- NSDownloadsFolderUsageDescription:
- "Application requests access to the user's Downloads folder.",
- CFBundleVersion: buildNumber,
- CFBundleDevelopmentRegion: 'en',
- CFBundleLocalizations: ['en', 'zh_CN']
- },
- target: [{ target: 'dmg', arch: ['x64', 'arm64'] }]
- },
- dmg: {
- artifactName: `\${name}-${pkg.version}.${buildNumber}-\${arch}.\${ext}`
- },
- // --- Linux 配置 ---
- linux: {
- target: ['AppImage', 'snap', 'deb'],
- maintainer: 'zycoo.com',
- category: 'Utility',
- artifactName: `\${name}-${pkg.version}.${buildNumber}.\${ext}`
- },
- appImage: {
- artifactName: `\${name}-${pkg.version}.${buildNumber}.\${ext}`
- },
- snap: {
- artifactName: `\${name}-${pkg.version}.${buildNumber}.\${ext}`
- },
- deb: {
- artifactName: `\${name}-${pkg.version}.${buildNumber}-\${arch}.\${ext}`
- },
- // --- 其他性能/下载配置 ---
- npmRebuild: false,
- electronDownload: {
- mirror: 'https://npmmirror.com/mirrors/electron/'
- }
- }
|