mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-02-10 19:50:28 +08:00
fix: use env var for win7 legacy build instead of regex replacement
This commit is contained in:
parent
ab58248d7b
commit
228e2cbffc
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -196,12 +196,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
pnpm install
|
pnpm install
|
||||||
pnpm add -D electron@22.3.27
|
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
|
(Get-Content electron-builder.yml) -replace 'windows', 'win7' | Set-Content electron-builder.yml
|
||||||
# Electron 22 requires CJS format
|
# Electron 22 requires CJS format
|
||||||
(Get-Content package.json) -replace '"type": "module"', '"type": "commonjs"' | Set-Content package.json
|
(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
|
- name: Update Version for Dev Build
|
||||||
if: github.event_name == 'workflow_dispatch'
|
if: github.event_name == 'workflow_dispatch'
|
||||||
env:
|
env:
|
||||||
@ -213,6 +210,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
npm_config_arch: ${{ matrix.arch }}
|
npm_config_arch: ${{ matrix.arch }}
|
||||||
npm_config_target_arch: ${{ matrix.arch }}
|
npm_config_target_arch: ${{ matrix.arch }}
|
||||||
|
LEGACY_BUILD: 'true'
|
||||||
run: pnpm build:win --${{ matrix.arch }}
|
run: pnpm build:win --${{ matrix.arch }}
|
||||||
- name: Add Portable Flag
|
- name: Add Portable Flag
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@ -15,14 +15,22 @@ const monacoEditorPlugin = isObjectWithDefaultFunction(monacoEditorPluginModule)
|
|||||||
? monacoEditorPluginModule.default
|
? monacoEditorPluginModule.default
|
||||||
: monacoEditorPluginModule
|
: 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({
|
export default defineConfig({
|
||||||
main: {
|
main: {
|
||||||
plugins: [externalizeDepsPlugin()]
|
plugins: isLegacyBuild ? [] : [externalizeDepsPlugin()],
|
||||||
|
build: isLegacyBuild
|
||||||
|
? { rollupOptions: { external: legacyExternal, output: { format: 'cjs' } } }
|
||||||
|
: undefined
|
||||||
},
|
},
|
||||||
preload: {
|
preload: {
|
||||||
plugins: [externalizeDepsPlugin()],
|
plugins: isLegacyBuild ? [] : [externalizeDepsPlugin()],
|
||||||
build: {
|
build: {
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
|
external: isLegacyBuild ? legacyExternal : undefined,
|
||||||
output: {
|
output: {
|
||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
entryFileNames: '[name].cjs'
|
entryFileNames: '[name].cjs'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user