-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathvite.config.ts
64 lines (61 loc) · 2.14 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
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import p from './package.json';
import visualizer from 'rollup-plugin-visualizer';
export default defineConfig(({ mode }) => {
const __isDev__ = mode === 'development';
return {
base: './',
plugins: [
// solidPlugin(),
{
enforce: 'pre',
resolveId(id) {
if (id === 'viewerjs') {
return {
external: true,
id: 'https://cdn.jsdelivr.net/npm/viewerjs@1.11.4/dist/viewer.esm.min.js',
};
}
},
transform(code, id) {
// 兼容 worker 模式
if (!__isDev__ && id.includes('/src/worker/index')) {
return code.replace(/{[^{]*?type:\s*?'module',*?[^}]*?}/g, '');
}
},
},
mode === 'analyze' &&
(visualizer({ open: true, filename: 'visualizer/stat.html' }) as any),
],
server: {
port: 3000,
proxy: {
// 配合 netlify 的云函数
'/.netlify/functions/upload_auth':
'http://localhost:9999/.netlify/functions/upload_auth',
'/.netlify/functions/status': 'http://localhost:9999/.netlify/functions/status',
},
},
// resolve: {
// alias: {
// '@fontsource/material-icons-rounded/index.css': '/src/index.css',
// // '@cn-ui/animate': '/node_modules/@cn-ui/animate/src/index.tsx',
// },
// },
define: {
__version__: JSON.stringify(p.version),
__isDev__: JSON.stringify(__isDev__),
},
// build: {
// rollupOptions: {
// input: {
// index: './index.html',
// gallery: './gallery.html',
// notebook: './notebook.html',
// },
// },
// },
worker: { format: 'iife' },
};
});