forked from openai-translator/openai-translator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.userscript.ts
51 lines (49 loc) · 1.9 KB
/
vite.config.userscript.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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'
import monkey, { cdn } from 'vite-plugin-monkey'
import { visualizer } from 'rollup-plugin-visualizer'
import svgr from 'vite-plugin-svgr'
import { fileURLToPath, URL } from 'url'
import { version, license, name } from './package.json'
const isDev = process.env.NODE_ENV === 'development'
export default defineConfig({
plugins: [
tsconfigPaths(),
react(),
svgr(),
monkey({
entry: 'src/browser-extension/content_script/index.tsx',
userscript: {
name,
icon: 'https://cdn.jsdelivr.net/gh/openai-translator/openai-translator/public/icon.png',
namespace: 'https://github.com/openai-translator/openai-translator',
match: ['*://*/*'],
author: 'https://github.com/openai-translator',
license,
description: {
'': '基于 ChatGPT API 的划词翻译浏览器插件和跨平台桌面端应用',
'en': 'Browser extension and cross-platform desktop application for translation based on ChatGPT API',
},
version,
},
build: {
externalGlobals: {
'react': cdn.jsdelivr('React', 'umd/react.production.min.js'),
'react-dom': cdn.jsdelivr('ReactDOM', 'umd/react-dom.production.min.js'),
'dexie': cdn.jsdelivr('Dexie', 'dist/dexie.min.js'),
},
},
}),
visualizer({ filename: 'dist/stats.html' }),
],
resolve: {
alias: [{ find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) }],
},
build: {
minify: !isDev,
sourcemap: isDev,
emptyOutDir: false,
rollupOptions: {},
},
})