mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-19 23:37:15 +08:00
fix(core): remove hash prefix from cdn path (#5509)
The hash prefix will cause cache invalidate during deployment It's for debug purpose but I forgot to remove it
This commit is contained in:
@@ -1,24 +1,11 @@
|
||||
import { join } from 'node:path';
|
||||
import { execSync } from 'node:child_process';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
import type { PutObjectCommandInput } from '@aws-sdk/client-s3';
|
||||
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
||||
import { once } from 'lodash-es';
|
||||
import { lookup } from 'mime-types';
|
||||
import type { Compiler, WebpackPluginInstance } from 'webpack';
|
||||
|
||||
export const gitShortHash = once(() => {
|
||||
const { GITHUB_SHA } = process.env;
|
||||
if (GITHUB_SHA) {
|
||||
return GITHUB_SHA.substring(0, 9);
|
||||
}
|
||||
const sha = execSync(`git rev-parse --short HEAD`, {
|
||||
encoding: 'utf-8',
|
||||
}).trim();
|
||||
return sha;
|
||||
});
|
||||
|
||||
export const R2_BUCKET =
|
||||
process.env.R2_BUCKET! ??
|
||||
(process.env.BUILD_TYPE === 'canary' ? 'assets-dev' : 'assets-prod');
|
||||
@@ -45,7 +32,7 @@ export class WebpackS3Plugin implements WebpackPluginInstance {
|
||||
const putObjectCommandOptions: PutObjectCommandInput = {
|
||||
Body: assetSource,
|
||||
Bucket: R2_BUCKET,
|
||||
Key: join(gitShortHash(), asset),
|
||||
Key: asset,
|
||||
};
|
||||
const contentType = lookup(asset);
|
||||
if (contentType) {
|
||||
|
||||
Reference in New Issue
Block a user