mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix: electron whitescreen (#4013)
This commit is contained in:
@@ -69,19 +69,20 @@ const OptimizeOptionOptions: (
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const publicPath = (function () {
|
export const getPublicPath = (buildFlags: BuildFlags) => {
|
||||||
const { BUILD_TYPE } = process.env;
|
const { BUILD_TYPE } = process.env;
|
||||||
const publicPath = process.env.PUBLIC_PATH ?? '/';
|
const publicPath = process.env.PUBLIC_PATH ?? '/';
|
||||||
if (process.env.COVERAGE) {
|
if (process.env.COVERAGE || buildFlags.distribution === 'desktop') {
|
||||||
return publicPath;
|
return publicPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BUILD_TYPE === 'canary') {
|
if (BUILD_TYPE === 'canary') {
|
||||||
return `https://dev.affineassets.com/${gitShortHash()}/`;
|
return `https://dev.affineassets.com/${gitShortHash()}/`;
|
||||||
} else if (BUILD_TYPE === 'beta' || BUILD_TYPE === 'stable') {
|
} else if (BUILD_TYPE === 'beta' || BUILD_TYPE === 'stable') {
|
||||||
return `https://prod.affineassets.com/${gitShortHash()}/`;
|
return `https://prod.affineassets.com/${gitShortHash()}/`;
|
||||||
}
|
}
|
||||||
return publicPath;
|
return publicPath;
|
||||||
})();
|
};
|
||||||
|
|
||||||
export const createConfiguration: (
|
export const createConfiguration: (
|
||||||
buildFlags: BuildFlags,
|
buildFlags: BuildFlags,
|
||||||
@@ -119,7 +120,7 @@ export const createConfiguration: (
|
|||||||
path: join(rootPath, 'dist'),
|
path: join(rootPath, 'dist'),
|
||||||
clean: buildFlags.mode === 'production',
|
clean: buildFlags.mode === 'production',
|
||||||
globalObject: 'globalThis',
|
globalObject: 'globalThis',
|
||||||
publicPath,
|
publicPath: getPublicPath(buildFlags),
|
||||||
},
|
},
|
||||||
target: ['web', 'es2022'],
|
target: ['web', 'es2022'],
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createConfiguration, rootPath, publicPath } from './config.js';
|
import { createConfiguration, rootPath, getPublicPath } from './config.js';
|
||||||
import { merge } from 'webpack-merge';
|
import { merge } from 'webpack-merge';
|
||||||
import { join, resolve } from 'node:path';
|
import { join, resolve } from 'node:path';
|
||||||
import type { BuildFlags } from '@affine/cli/config';
|
import type { BuildFlags } from '@affine/cli/config';
|
||||||
@@ -55,7 +55,7 @@ export default async function (cli_env: any, _: any) {
|
|||||||
inject: 'body',
|
inject: 'body',
|
||||||
scriptLoading: 'module',
|
scriptLoading: 'module',
|
||||||
minify: false,
|
minify: false,
|
||||||
publicPath,
|
publicPath: getPublicPath(flags),
|
||||||
chunks: [
|
chunks: [
|
||||||
'_plugin/index.test',
|
'_plugin/index.test',
|
||||||
'plugin',
|
'plugin',
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ async function handleHttpRequest(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function registerProtocol() {
|
export function registerProtocol() {
|
||||||
// it seems that there is some issue to postMessage between renderer with custom protocol & helper process
|
|
||||||
protocol.handle('http', request => {
|
protocol.handle('http', request => {
|
||||||
return handleHttpRequest(request);
|
return handleHttpRequest(request);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user