diff --git a/packages/frontend/core/.webpack/config.ts b/packages/frontend/core/.webpack/config.ts index e9a92b2008..050bb6dc0f 100644 --- a/packages/frontend/core/.webpack/config.ts +++ b/packages/frontend/core/.webpack/config.ts @@ -18,7 +18,7 @@ import type { BuildFlags } from '@affine/cli/config'; import { projectRoot } from '@affine/cli/config'; import { VanillaExtractPlugin } from '@vanilla-extract/webpack-plugin'; import type { RuntimeConfig } from '@affine/env/global'; -import { WebpackS3Plugin, gitShortHash } from './s3-plugin.js'; +import { WebpackS3Plugin } from './s3-plugin.js'; const IN_CI = !!process.env.CI; @@ -81,9 +81,9 @@ export const getPublicPath = (buildFlags: BuildFlags) => { } if (BUILD_TYPE === 'canary') { - return `https://dev.affineassets.com/${gitShortHash()}/`; + return `https://dev.affineassets.com/`; } else if (BUILD_TYPE === 'beta' || BUILD_TYPE === 'stable') { - return `https://prod.affineassets.com/${gitShortHash()}/`; + return `https://prod.affineassets.com/`; } return publicPath; }; diff --git a/packages/frontend/core/.webpack/s3-plugin.ts b/packages/frontend/core/.webpack/s3-plugin.ts index 35b4b8c269..83b51a790f 100644 --- a/packages/frontend/core/.webpack/s3-plugin.ts +++ b/packages/frontend/core/.webpack/s3-plugin.ts @@ -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) { diff --git a/packages/frontend/core/.webpack/webpack.config.ts b/packages/frontend/core/.webpack/webpack.config.ts index a9c82e0c38..17460fa873 100644 --- a/packages/frontend/core/.webpack/webpack.config.ts +++ b/packages/frontend/core/.webpack/webpack.config.ts @@ -1,14 +1,27 @@ -import { createConfiguration, rootPath } from './config.js'; -import { merge } from 'webpack-merge'; +import { execSync } from 'node:child_process'; import { join, resolve } from 'node:path'; + +import { once } from 'lodash-es'; +import { merge } from 'webpack-merge'; import type { BuildFlags } from '@affine/cli/config'; -import { getRuntimeConfig } from './runtime-config.js'; import HTMLPlugin from 'html-webpack-plugin'; -import { gitShortHash } from './s3-plugin.js'; +import { getRuntimeConfig } from './runtime-config.js'; +import { createConfiguration, rootPath } from './config.js'; const DESCRIPTION = `There can be more than Notion and Miro. AFFiNE is a next-gen knowledge base that brings planning, sorting and creating all together.`; +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 default async function (cli_env: any, _: any) { const flags: BuildFlags = JSON.parse( Buffer.from(cli_env.flags, 'hex').toString('utf-8')