-
Notifications
You must be signed in to change notification settings - Fork 4
/
vite.config.ts
115 lines (111 loc) · 2.74 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
109
110
111
112
113
114
115
import { defineConfig, UserConfigExport, UserConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import * as path from 'path';
import Icons from 'unplugin-icons/vite';
import Components from 'unplugin-vue-components/vite';
import IconsResolver from 'unplugin-icons/resolver';
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
const userConfig: UserConfig = {
css: {
postcss: {
plugins: [require('postcss-import'), require('tailwindcss'), require('autoprefixer')],
},
},
resolve: {
alias: {
'~views/': `${path.resolve(__dirname, './src/views')}/`,
'~/': `${path.resolve(__dirname, './src')}/`,
},
},
define: {},
server: {
host: '0.0.0.0',
port: 5173,
watch: {
ignored: ['./config/*', './locales/*'],
},
},
esbuild: {
pure: ['console.log'],
},
optimizeDeps: {
esbuildOptions: {
define: {
global: 'globalThis',
},
},
},
build: {
outDir: 'dist',
assetsDir: 'assets',
manifest: true,
chunkSizeWarningLimit: 533,
rollupOptions: {
plugins: [
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true,
}),
],
output: {
manualChunks: {
e: ['ethers'],
v: ['vue', 'vue-router'],
},
},
},
},
plugins: [
vue(),
// VueI18n({
// runtimeOnly: true,
// compositionOnly: true,
// include: [path.resolve(__dirname, 'locales/**')],
// }),
Icons({
scale: 1.2,
autoInstall: true,
compiler: 'vue3',
customCollections: {
logo: FileSystemIconLoader('./src/assets/logo', (svg) =>
svg.replace(/^<svg /, '<svg fill="currentColor" '),
),
coin: FileSystemIconLoader('./src/assets/coins', (svg) =>
svg.replace(/^<svg /, '<svg fill="currentColor" '),
),
},
iconCustomizer(collection, icon, props) {
// customize this icon in this collection
if (['logo', 'coin'].includes(collection)) {
props.class = 'icon inline ';
}
},
}),
Components({
resolvers: [
IconsResolver({
prefix: 'icon',
}),
],
dts: 'src/components.d.ts',
dirs: ['src/views/components/'],
}),
],
};
export default defineConfig(({ command }) => {
if (command === 'serve') {
userConfig.define = {
process: process,
};
userConfig.resolve = {
...userConfig.resolve,
alias: {
...userConfig.resolve?.alias,
util: 'rollup-plugin-node-polyfills/polyfills/util',
tty: 'rollup-plugin-node-polyfills/polyfills/tty',
},
};
}
return userConfig;
});