fix: use env var for win7 legacy build instead of regex replacement

This commit is contained in:
xmk23333 2026-01-15 23:11:37 +08:00
parent ab58248d7b
commit 228e2cbffc
2 changed files with 11 additions and 5 deletions

View File

@ -196,12 +196,9 @@ jobs:
run: |
pnpm install
pnpm add -D electron@22.3.27
# Downgrade packages incompatible with Node.js 16 (Electron 22)
pnpm add express@4.21.2 chokidar@3.6.0
(Get-Content electron-builder.yml) -replace 'windows', 'win7' | Set-Content electron-builder.yml
# Electron 22 requires CJS format
(Get-Content package.json) -replace '"type": "module"', '"type": "commonjs"' | Set-Content package.json
(Get-Content electron.vite.config.ts) -replace 'plugins: \[externalizeDepsPlugin\(\)\]', "plugins: [externalizeDepsPlugin()],`n build: { rollupOptions: { output: { format: 'cjs' } } }" | Set-Content electron.vite.config.ts
- name: Update Version for Dev Build
if: github.event_name == 'workflow_dispatch'
env:
@ -213,6 +210,7 @@ jobs:
env:
npm_config_arch: ${{ matrix.arch }}
npm_config_target_arch: ${{ matrix.arch }}
LEGACY_BUILD: 'true'
run: pnpm build:win --${{ matrix.arch }}
- name: Add Portable Flag
run: |

View File

@ -15,14 +15,22 @@ const monacoEditorPlugin = isObjectWithDefaultFunction(monacoEditorPluginModule)
? monacoEditorPluginModule.default
: monacoEditorPluginModule
// Win7 build: bundle all deps (Vite converts ESM→CJS), only externalize native modules
const isLegacyBuild = process.env.LEGACY_BUILD === 'true'
const legacyExternal = ['sysproxy-rs', 'electron']
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()]
plugins: isLegacyBuild ? [] : [externalizeDepsPlugin()],
build: isLegacyBuild
? { rollupOptions: { external: legacyExternal, output: { format: 'cjs' } } }
: undefined
},
preload: {
plugins: [externalizeDepsPlugin()],
plugins: isLegacyBuild ? [] : [externalizeDepsPlugin()],
build: {
rollupOptions: {
external: isLegacyBuild ? legacyExternal : undefined,
output: {
format: 'cjs',
entryFileNames: '[name].cjs'