feat: add CI for publishing chrome extension (#1568)

* fix: remove the permission not needed and update the player style link

* fix: change the way of importing worker script

* improve the extension version

* build: add process env to disable inline worker import

* improve style file

* upgrade svelte2tsx

* disable eslint check for that line

* merge the extension-release action into release action

---------

Co-authored-by: YunFeng0817 <YunFeng0817@users.noreply.github.com>
This commit is contained in:
Yun Feng
2026-04-01 12:00:00 +08:00
committed by GitHub
parent f993bb5c88
commit 3211ded262
12 changed files with 130 additions and 26 deletions

View File

@@ -4,6 +4,7 @@ import zip from 'vite-plugin-zip-pack';
import * as path from 'path';
import type { PackageJson } from 'type-fest';
import react from '@vitejs/plugin-react';
import semver from 'semver';
const emptyOutDir = !process.argv.includes('--watch');
@@ -39,6 +40,29 @@ function useSpecialFormat(
};
}
/**
* Get the extension version based on the rrweb version.
*/
function getExtensionVersion(rrwebVersion: string): string {
const parsedVersion = semver.parse(rrwebVersion.replace('^', ''));
if (!parsedVersion) {
throw new Error('Invalid version format');
}
if (parsedVersion.prerelease.length > 0) {
// If it's a pre-release version like alpha or beta, strip the pre-release identifier
return `${parsedVersion.major}.${parsedVersion.minor}.${
parsedVersion.patch
}.${parsedVersion.prerelease[1] || 0}`;
} else if (rrwebVersion === '2.0.0') {
// This version has already been released as the first version. We need to add a patch version to it to avoid publishing conflicts.
return '2.0.0.100';
} else {
return rrwebVersion;
}
}
export default defineConfig({
root: 'src',
// Configure our outputs - nothing special, this is normal vite config
@@ -73,10 +97,11 @@ export default defineConfig({
const BrowserName =
process.env.TARGET_BROWSER === 'chrome' ? 'chrome' : 'firefox';
const commonManifest = originalManifest.common;
const rrwebVersion = packageJson.dependencies!.rrweb!.replace('^', '');
const manifest = {
version: '2.0.0',
version: getExtensionVersion(rrwebVersion),
author: packageJson.author,
version_name: packageJson.dependencies?.rrweb?.replace('^', ''),
version_name: rrwebVersion,
...commonManifest,
};
Object.assign(
@@ -92,7 +117,7 @@ export default defineConfig({
watchIgnored: ['*.md', '*.log'],
},
additionalInputs: ['pages/index.html', 'content/inject.ts'],
}),
}) as PluginOption,
// https://github.com/aklinker1/vite-plugin-web-extension/issues/50#issuecomment-1317922947
// transfer inject.ts to iife format to avoid error
useSpecialFormat(