1/**
2 * Vite ์ค์ ํ์ผ
3 * https://vitejs.dev/config/
4 */
5
6import { defineConfig } from 'vite';
7import { resolve } from 'path';
8
9export default defineConfig({
10 // ๊ฐ๋ฐ ์๋ฒ ์ค์
11 server: {
12 port: 3000, // ํฌํธ ๋ฒํธ
13 open: true, // ๋ธ๋ผ์ฐ์ ์๋ ์ด๊ธฐ
14 cors: true, // CORS ํ์ฉ
15 host: true, // ๋คํธ์ํฌ์์ ์ ๊ทผ ํ์ฉ
16 // ํ๋ก์ ์ค์ (API ์๋ฒ ์ฐ๋ ์)
17 // proxy: {
18 // '/api': {
19 // target: 'http://localhost:8080',
20 // changeOrigin: true,
21 // rewrite: (path) => path.replace(/^\/api/, '')
22 // }
23 // }
24 },
25
26 // ๋น๋ ์ค์
27 build: {
28 outDir: 'dist', // ์ถ๋ ฅ ๋๋ ํ ๋ฆฌ
29 sourcemap: true, // ์์ค๋งต ์์ฑ
30 minify: 'terser', // ์์ถ ๋ฐฉ์ (terser ๋๋ esbuild)
31 target: 'es2020', // ํ๊ฒ ๋ธ๋ผ์ฐ์
32
33 // ๋ฒ๋ค ๋ถํ ์ค์
34 rollupOptions: {
35 input: {
36 main: resolve(__dirname, 'index.html'),
37 // ๋ค์ค ํ์ด์ง ์ฑ์ ๊ฒฝ์ฐ
38 // about: resolve(__dirname, 'about.html'),
39 },
40 output: {
41 // ์ฒญํฌ ํ์ผ ์ด๋ฆ ํจํด
42 chunkFileNames: 'assets/js/[name]-[hash].js',
43 entryFileNames: 'assets/js/[name]-[hash].js',
44 assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
45
46 // ๋ฒค๋ ๋ฒ๋ค ๋ถ๋ฆฌ
47 manualChunks: {
48 // vendor: ['lodash', 'axios'],
49 }
50 }
51 },
52
53 // ์ฒญํฌ ํฌ๊ธฐ ๊ฒฝ๊ณ ์๊ณ๊ฐ (KB)
54 chunkSizeWarningLimit: 500,
55 },
56
57 // ๊ฒฝ๋ก ๋ณ์นญ ์ค์
58 resolve: {
59 alias: {
60 '@': resolve(__dirname, 'src'),
61 '@components': resolve(__dirname, 'src/components'),
62 '@utils': resolve(__dirname, 'src/utils'),
63 '@styles': resolve(__dirname, 'src/styles'),
64 }
65 },
66
67 // CSS ์ค์
68 css: {
69 // CSS ๋ชจ๋ ์ค์
70 modules: {
71 localsConvention: 'camelCase',
72 },
73 // PostCSS ์ค์
74 postcss: {
75 plugins: [
76 // autoprefixer ๋ฑ ํ๋ฌ๊ทธ์ธ ์ถ๊ฐ
77 ]
78 },
79 // ์ ์ฒ๋ฆฌ๊ธฐ ์ต์
80 preprocessorOptions: {
81 scss: {
82 // ์ ์ญ ๋ณ์ ํ์ผ ์๋ import
83 // additionalData: `@import "@/styles/variables.scss";`
84 }
85 }
86 },
87
88 // ํ๊ฒฝ ๋ณ์ ์ ๋์ฌ
89 envPrefix: 'VITE_',
90
91 // ํ๋ฌ๊ทธ์ธ
92 plugins: [
93 // @vitejs/plugin-react
94 // @vitejs/plugin-vue
95 // @vitejs/plugin-legacy (๊ตฌํ ๋ธ๋ผ์ฐ์ ์ง์)
96 ],
97
98 // ์ต์ ํ ์ค์
99 optimizeDeps: {
100 // ์ฌ์ ๋ฒ๋ค๋งํ ์์กด์ฑ
101 include: [],
102 // ์ฌ์ ๋ฒ๋ค๋ง์์ ์ ์ธํ ์์กด์ฑ
103 exclude: []
104 },
105
106 // ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์๋ฒ ์ค์
107 preview: {
108 port: 4173,
109 open: true,
110 }
111});