forked from Tsuk1ko/nhentai-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
93 lines (92 loc) · 2.92 KB
/
vite.config.ts
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
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import monkey, { cdn, util } from 'vite-plugin-monkey';
import copy from 'rollup-plugin-copy';
import vueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
import workerDevLoader from './plugins/workerDevLoader';
// https://vitejs.dev/config/
export default defineConfig(async ({ mode }) => ({
server: {
open: false,
},
preview: {
open: true,
},
build: {
cssMinify: true,
},
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
plugins: [
workerDevLoader(),
vue(),
vueI18nPlugin({
include: resolve(dirname(fileURLToPath(import.meta.url)), './src/i18n/locales/**'),
strictMessage: false,
}),
monkey({
entry: 'src/main.ts',
userscript: {
name: {
'': 'nHentai Helper',
'zh-CN': 'nHentai 助手',
'zh-TW': 'nHentai 助手',
},
icon: 'https://icon.horse/icon/nhentai.net',
namespace: 'https://github.com/Tsuk1ko',
description: {
'': 'Download nHentai manga as compression file easily, and add some useful features. Also support some mirror sites.',
'zh-CN': '为 nHentai 增加压缩打包下载方式以及一些辅助功能,同时还支持一些镜像站',
'zh-TW': '爲 nHentai 增加壓縮打包下載方式以及一些輔助功能,同時還支援一些鏡像站',
},
match: [
'https://nhentai.net/*',
'https://nhentai.xxx/*',
'https://nhentai.to/*',
'https://nhentai.website/*',
...(mode === 'development' ? ['https://nhelper.lolicon.app/dev.html'] : []),
],
include: /^https:\/\/([^/]*\.)?(nya|dog|cat|bug|qq|fox|ee|yy)hentai[0-9]*\./,
connect: [
'nhentai.net',
'i.nhentai.net',
'i2.nhentai.net',
'i3.nhentai.net',
'i5.nhentai.net',
'i7.nhentai.net',
'*',
],
'run-at': 'document-end',
noframes: true,
homepageURL: 'https://github.com/Tsuk1ko/nhentai-helper',
supportURL: 'https://github.com/Tsuk1ko/nhentai-helper/issues',
},
build: {
fileName: 'script.user.js',
metaFileName: true,
externalGlobals: {
vue: cdn.unpkg('Vue', 'dist/vue.global.prod.js').concat(
await util.fn2dataUrl(() => {
// @ts-expect-error
window.Vue = Vue;
}),
),
'element-plus': cdn.unpkg('ElementPlus', 'dist/index.full.min.js'),
jquery: cdn.unpkg('jQuery', 'dist/jquery.min.js'),
},
externalResource: {
'element-plus/dist/index.css': cdn.unpkg('element-plus-css'),
},
},
}),
copy({
targets: [{ src: ['docs/*.html'], dest: 'dist' }],
hook: 'writeBundle',
}),
],
}));