forked from wfjsw/danbooru-diffusion-prompt-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
108 lines (107 loc) · 3.11 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import yaml from '@rollup/plugin-yaml'
import ElementPlus from 'unplugin-element-plus/vite'
import { resolve } from 'path'
import { VitePluginRadar } from 'vite-plugin-radar'
import { visualizer } from 'rollup-plugin-visualizer'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
yaml(),
ElementPlus({ useSource: true }),
{
...VitePluginRadar({
analytics: {
id: 'G-WYETBX79HJ',
},
}),
apply(config, { command }) {
return command === 'build' && config.mode === 'production'
},
},
visualizer(),
],
resolve: {
alias: [
{
find: '@',
replacement: '/src',
},
{
find: /^@fortawesome\/fontawesome-svg-core$/,
replacement: resolve(
__dirname,
'./src/fontawesome-svg-core.js'
),
},
{
find: '~/',
replacement: `${resolve(__dirname, 'src')}/`,
},
],
},
css: {
preprocessorOptions: {
scss: {
additionalData: (content, path) => {
if (path.includes('node_modules/element-plus')) {
return `@use "~/variables.scss" as *;\n${content}`
}
return content
},
},
},
},
esbuild: {
legalComments: 'eof',
},
build: {
target: 'esnext',
rollupOptions: {
treeshake: {
preset: 'smallest',
moduleSideEffects: true,
},
output: {
compact: true,
manualChunks(id) {
if (
id.includes('/node_modules/vue') ||
id.includes('node_modules/@vue') ||
id.includes('node_modules/lodash')
) {
return 'vendor-1'
}
if (
id.includes('/node_modules/element-plus') ||
id.includes('node_modules/@fortawesome')
) {
return 'vendor-2'
}
if (id.includes('/node_modules/')) {
return 'vendor-3'
}
if (
id.includes('/data/tags') ||
id.includes('/data/danbooru_tag_post_count.json')
) {
return 'data-1'
}
if (id.includes('/data/')) {
return 'data-2'
}
},
},
},
},
ssr: {
noExternal: true,
external: ['masonry-layout'],
},
clearScreen: false,
define: {
__BUILD_TIMESTAMP__: Date.now(),
},
})