forked from wdhive/todo-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
54 lines (47 loc) · 1.21 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
import path from 'path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import svgr from '@honkhonk/vite-plugin-svgr';
const isDevMode = process.env.NODE_ENV === 'development';
const config = {
assestPath: 'assets',
};
const server = {
port: 80,
};
const build = {
rollupOptions: {
output: {
assetFileNames: file => {
const ext = file.name.split('.').at(-1);
const outputFolder = ext === 'css' || ext === 'js' ? '' : 'files/';
return `${config.assestPath}/${outputFolder}[name]-[hash][extname]`;
},
chunkFileNames: `${config.assestPath}/chunk-[name]-[hash].js`,
entryFileNames: `${config.assestPath}/[name]-[hash].js`,
},
},
};
const plugins = [react(), svgr.default()];
const css = {
modules: {
generateScopedName: isDevMode
? '[local]___[name]--[hash:base64:5]'
: '[hash:base64]',
},
};
const resolve = {
alias: {
'@src': path.resolve(__dirname, './src'),
'@com': path.resolve(__dirname, './src/components'),
'@lay': path.resolve(__dirname, './src/layouts'),
'@pages': path.resolve(__dirname, './src/pages'),
},
};
export default defineConfig({
resolve,
server,
build,
plugins,
css,
});