Skip to content

Commit

Permalink
deploy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
caipira113 committed Oct 26, 2023
1 parent 20773dc commit adf6299
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/frontend/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ declare const _PERF_PREFIX_: string;
declare const _DATA_TRANSFER_DRIVE_FILE_: string;
declare const _DATA_TRANSFER_DRIVE_FOLDER_: string;
declare const _DATA_TRANSFER_DECK_COLUMN_: string;
declare const _CLIENT_ASSETS_BASE_URL_: string;
2 changes: 1 addition & 1 deletion packages/frontend/src/boot/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export async function common(createVue: () => App<Element>) {
const localeVersion = miLocalStorage.getItem('localeVersion');
const localeOutdated = (localeVersion == null || localeVersion !== version || lastBasedMisskeyVersion !== basedMisskeyVersion);
if (localeOutdated) {
const res = await window.fetch(`/assets/locales/${lang}.${version}.json`);
const res = await window.fetch(`${_CLIENT_ASSETS_BASE_URL_}/assets/locales/${lang}.${version}.json`);
if (res.status === 200) {
const newLocale = await res.text();
const parsedNewLocale = JSON.parse(newLocale);
Expand Down
7 changes: 6 additions & 1 deletion packages/frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ function toBase62(n: number): string {
return result;
}

const CLIENT_ASSETS_BASE_URL = process.env.CLIENT_ASSETS_BASE_URL;
const CLIENT_ASSETS_DIR = process.env.CLIENT_ASSETS_DIR;
const clientAssetsBaseUrl = CLIENT_ASSETS_BASE_URL && CLIENT_ASSETS_DIR ? `${CLIENT_ASSETS_BASE_URL}/${CLIENT_ASSETS_DIR}` : "";

export function getConfig(): UserConfig {
return {
base: '/vite/',
Expand All @@ -54,7 +58,7 @@ export function getConfig(): UserConfig {
if (filename.includes('draw-blurhash') || filename.includes('test-webgl2')) {
return '/vite/' + filename
} else if (process.env.CLIENT_ASSETS_BASE_URL && process.env.CLIENT_ASSETS_DIR) {
return `${process.env.CLIENT_ASSETS_BASE_URL}/${process.env.CLIENT_ASSETS_DIR}/vite/${filename}`
return `${clientAssetsBaseUrl}/vite/${filename}`
} else {
return '/vite/' + filename
}
Expand Down Expand Up @@ -114,6 +118,7 @@ export function getConfig(): UserConfig {
_DATA_TRANSFER_DRIVE_FILE_: JSON.stringify('mk_drive_file'),
_DATA_TRANSFER_DRIVE_FOLDER_: JSON.stringify('mk_drive_folder'),
_DATA_TRANSFER_DECK_COLUMN_: JSON.stringify('mk_deck_column'),
_CLIENT_ASSETS_BASE_URL_: JSON.stringify(clientAssetsBaseUrl),
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false,
},
Expand Down
3 changes: 2 additions & 1 deletion packages/sw/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const __dirname = fileURLToPath(new URL('.', import.meta.url))

const CLIENT_ASSETS_BASE_URL = process.env.CLIENT_ASSETS_BASE_URL;
const CLIENT_ASSETS_DIR = process.env.CLIENT_ASSETS_DIR;
const clientAssetsBaseUrl = CLIENT_ASSETS_BASE_URL && CLIENT_ASSETS_DIR ? `${CLIENT_ASSETS_BASE_URL}/${CLIENT_ASSETS_DIR}` : "";

console.log('Starting SW building...');

Expand All @@ -29,7 +30,7 @@ const buildOptions = {
_PERF_PREFIX_: JSON.stringify('CherryPick:'),
_VERSION_: JSON.stringify(meta.version),
_BASEDMISSKEYVERSION_: JSON.stringify(meta.basedMisskeyVersion),
_CLIENT_ASSETS_BASE_URL_: JSON.stringify(CLIENT_ASSETS_BASE_URL && CLIENT_ASSETS_DIR ? `${CLIENT_ASSETS_BASE_URL}/${CLIENT_ASSETS_DIR}` : ""),
_CLIENT_ASSETS_BASE_URL_: JSON.stringify(clientAssetsBaseUrl),
},
entryPoints: [`${__dirname}/src/sw.ts`],
format: 'esm',
Expand Down

0 comments on commit adf6299

Please sign in to comment.