-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
88 lines (82 loc) · 1.98 KB
/
vite.config.js
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
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import { fileURLToPath } from 'node:url';
import packageJson from './package.json';
// import { ViteDevServer } from 'vite';
export function pluginWatchNodeModules(modules) {
// Merge module into pipe separated string for RegExp() below.
let pattern = `/node_modules\\/(?!${modules.join('|')}).*/`;
return {
name: 'watch-node-modules',
configureServer: (server) => {
server.watcher.options = {
...server.watcher.options,
ignored: [
new RegExp(pattern),
'**/.git/**',
]
}
}
}
}
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '');
// const entries = Object.fromEntries(
// Object.entries(env).map(([key, val]) => {
// if (key.startsWith('TOMMY_')) {
// return [
// [`import.meta.env.${key}`, val],
// [`process.env.${key}`, val],
// ]
// }
// }).filter(Boolean).flat());
Object.entries(env).map(([key, val]) => {
if (key.startsWith('TOMMY_')) {
process.env[key] = val
}
})
return {
plugins: [vue(), pluginWatchNodeModules(['tommy-core'])],
envPrefix: 'TOMMY_',
// define: entries,
server: {
port: 8080,
fs: {
allow: [
'addons',
'src',
'node_modules/@fontsource'
],
},
},
resolve: {
alias: [
{
find: '@',
replacement: path.resolve(__dirname, 'src')
},
{
find: 'tommy-core',
replacement: path.resolve(__dirname, '../tommy-core')
}
]
},
build: {
chunkSizeWarningLimit: 600,
cssCodeSplit: false,
rollupOptions: {
external: [
'vuex',
fileURLToPath(
new URL(
'node_modules/vuex/dist/vuex.esm-bundler.js',
import.meta.url
)
),
/node_modules/
]
}
}
}
});