-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathvite.config.ts
48 lines (47 loc) · 1.22 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
import {defineConfig, loadEnv} from 'vite';
import reactPlugin from '@vitejs/plugin-react';
import checker from 'vite-plugin-checker';
import path from "path";
import typedVariables from 'dotenv-parse-variables';
import proxyConfig from "./proxy.config";
export default defineConfig(params => {
const env = typedVariables(loadEnv(params.mode, process.cwd(), '')) as ImportMetaEnv;
return {
root: 'src',
base: env.BASE_URL,
build: {
outDir: params.isSsrBuild ? '../dist/server' : '../dist/client',
emptyOutDir: true,
cssCodeSplit: false
},
ssr: {
// Названия пакетов, которые нужно добавить в сборку при SSR вместо импорта из node_modules
noExternal: [
'react-helmet-async'
]
},
resolve: {
alias: {
'@src': path.resolve(__dirname, './src'),
}
},
plugins: [
reactPlugin({
include: '**/*.{jsx,tsx}',
}),
checker({
// e.g. use TypeScript check
typescript: true,
overlay: false
}),
],
server: {
port: env.PORT,
proxy: proxyConfig(env),
hmr: true
},
preview: {
port: env.PORT,
},
};
});