-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
vite.config.js
99 lines (96 loc) · 2.87 KB
/
vite.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { defineConfig } from 'vite';
import preact from '@preact/preset-vite';
import monkey, { cdn } from 'vite-plugin-monkey';
import svgr from 'vite-plugin-svgr';
import { yamlToJSON } from './scripts/helper.js';
import chokidar from 'chokidar';
const cmd = process.argv.slice(2)[0];
const isDev = cmd === 'dev';
export default defineConfig({
plugins: [
{
name: 'watch-yaml',
buildStart () {
yamlToJSON();
if (!isDev) return;
chokidar.watch(
['src/config/*.yaml', 'src/i18n/*.yaml'],
{
awaitWriteFinish: {
stabilityThreshold: 200,
pollInterval: 100,
},
ignoreInitial: true,
},
).on('all', (eventName, path) => {
console.log(`${path}:${eventName}`);
yamlToJSON();
});
},
},
preact(),
svgr({
svgrOptions: { exportType: 'default', ref: true, svgo: false, titleProp: true },
include: '**/*.svg',
}),
monkey({
entry: 'src/index.tsx',
userscript: {
name: {
'': 'EasyUpload PT一键转种',
en: 'EasyUpload - Trackers Transfer Tool',
},
description: {
'': '一键转种,支持PT站点之间的种子转移。',
en: 'Transfer torrents between trackers with one click.',
},
namespace: 'https://github.com/techmovie/easy-upload',
match: [
'http*://*/torrents.php?id=*',
'http*://*/torrents.php?torrentid=*',
'http*://*/details.php?id=*',
'https://totheglory.im/t/*',
'http*://*/torrents/*',
'http*://*/torrents?*',
'http*://*/upload*',
'https://*/offers.php*',
'https://broadcity.in/browse.php?imdb=*',
'https://*/torrent/*',
'https://piratethenet.org/browse.php?*',
'https://teamhd.org/details/id*',
'https://hd-space.org/index.php?page=upload',
'https://hd-space.org/index.php?page=torrent-details&id=*',
'https://speedapp.io/browse/*',
'https://*.m-team.cc/detail/*',
],
exclude: [
'https://*/torrent/peers*',
'https://*/torrent/leechers*',
'https://*/torrent/history*',
],
downloadURL: 'https://github.com/techmovie/easy-upload/raw/master/dist/easy-upload.user.js',
updateURL: 'https://github.com/techmovie/easy-upload/raw/master/dist/easy-upload.user.js',
license: 'MIT',
},
build: {
externalGlobals: {
preact: cdn.jsdelivr('preact', 'dist/preact.min.js'),
jquery: cdn.jsdelivr('jQuery', 'dist/jquery.min.js'),
},
},
server: {
mountGmApi: true,
},
}),
],
build: {
minifyCss: true,
target: 'chrome58',
outDir: './dist',
},
resolve: {
alias: {
path: 'path-browserify',
},
},
});