mirror of
https://github.com/naiyQAQ/fanqie-assistant.git
synced 2026-10-21 10:24:47 +00:00
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import monkey from 'vite-plugin-monkey';
|
|
import vue from '@vitejs/plugin-vue';
|
|
import { version } from './package.json';
|
|
import { readFileSync } from 'node:fs';
|
|
|
|
const tocdn = (
|
|
exportVarName: string,
|
|
pathname: string,
|
|
): [string, (version: string, name: string) => string] => [
|
|
exportVarName,
|
|
(version, name) => `https://registry.npmmirror.com/${name}/${version}/files/${pathname}`,
|
|
];
|
|
|
|
const icon = readFileSync('./src/assets/fanqie.svg', 'utf-8');
|
|
const iconUrl = `data:image/svg+xml;base64,${Buffer.from(icon).toString('base64')}`;
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
monkey({
|
|
entry: 'src/main.ts',
|
|
userscript: {
|
|
name: '番茄小说助手',
|
|
namespace: 'https://github.com/naiyQAQ/fanqie-assistant',
|
|
license: "GPLv3",
|
|
version,
|
|
description: '番茄小说助手,去广告、去推广、解锁章节、优化体验。',
|
|
icon: iconUrl,
|
|
author: 'naiyQAQ',
|
|
'run-at': 'document-start',
|
|
match: ['*://*.fanqienovel.com/*'],
|
|
grant: ['GM_addStyle', 'GM_getValue', 'GM_setValue', 'GM_deleteValue', 'GM_xmlhttpRequest', 'unsafeWindow'],
|
|
connect: ['fanqienovel.com', 'api5-sinfonlinec.jxbhmy.com', 'api3-sinfonlinec.jxbhmy.com', 'reading.snssdk.com'],
|
|
},
|
|
build: {
|
|
fileName: 'fanqie-assistant.user.js',
|
|
// vue / moment 走 CDN @require,不打进脚本体积
|
|
externalGlobals: {
|
|
vue: tocdn('Vue', 'dist/vue.global.prod.js'),
|
|
moment: tocdn('moment', 'min/moment.min.js'),
|
|
},
|
|
},
|
|
}),
|
|
],
|
|
});
|