build: move cdn to npmmirror due to greasyfork restricts

This commit is contained in:
naiy committed 2026-07-31 04:47:35 +08:00
1 parent 8d84353613
commit 6ff79c3e65
1 file changed
+4 -9
+4 -9
View File
@@ -4,17 +4,12 @@ import vue from '@vitejs/plugin-vue';
import { version } from './package.json'; import { version } from './package.json';
import { readFileSync } from 'node:fs'; import { readFileSync } from 'node:fs';
/** const tocdn = (
* Zstatic 是 npm 全量镜像,路径与 jsdelivr 的 /npm/ 完全一致,
* 文件内容逐字节相同,但在大陆的连通性远好于 cdn.jsdelivr.net。
* 用法同 cdn.jsdelivr:zstatic(导出的全局变量名, 包内文件路径)
*/
const zstatic = (
exportVarName: string, exportVarName: string,
pathname: string, pathname: string,
): [string, (version: string, name: string) => string] => [ ): [string, (version: string, name: string) => string] => [
exportVarName, exportVarName,
(version, name) => `https://s4.zstatic.net/npm/${name}@${version}/${pathname}`, (version, name) => `https://registry.npmmirror.com/${name}/${version}/files/${pathname}`,
]; ];
const icon = readFileSync('./src/assets/fanqie.svg', 'utf-8'); const icon = readFileSync('./src/assets/fanqie.svg', 'utf-8');
@@ -42,8 +37,8 @@ export default defineConfig({
fileName: 'fanqie-assistant.user.js', fileName: 'fanqie-assistant.user.js',
// vue / moment 走 CDN @require,不打进脚本体积 // vue / moment 走 CDN @require,不打进脚本体积
externalGlobals: { externalGlobals: {
vue: zstatic('Vue', 'dist/vue.global.prod.js'), vue: tocdn('Vue', 'dist/vue.global.prod.js'),
moment: zstatic('moment', 'min/moment.min.js'), moment: tocdn('moment', 'min/moment.min.js'),
}, },
}, },
}), }),