-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
60 lines (57 loc) · 1.35 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
import { defineConfig } from 'vite'
import compression from 'vite-plugin-compression'
import visualizer from 'rollup-plugin-visualizer'
export default defineConfig(({ command, mode }) => {
console.log(mode, command)
const config = {
root: 'src',
cacheDir: '../.yarn/cache/.vite',
plugins: [
// Compress assets
compression({
ext: 'br',
algorithm: 'brotliCompress',
threshold: 256,
verbose: false,
filter: /\.(js|css|svg)$/i
})
],
server: {
open: process.argv.includes('--open')
},
resolve: {
alias: []
},
build: {
outDir: '../build',
manifest: true,
emptyOutDir: true,
cssCodeSplit: false,
rollupOptions: {
input: {
app: './src/index.html'
},
output: {
// Custom output naming
assetFileNames: 'web/[name].[ext]',
entryFileNames: 'web/[name].js',
chunkFileNames: 'web/[name].js',
// Put all modules in single chunk
manualChunks: () => 'app',
}
}
}
}
// Open a bundle visualizer
if (mode === 'analyze') {
config.plugins?.push(
visualizer({
title: 'Vite Bundle Report',
filename: '.yarn/cache/.vite/report.html',
brotliSize: true,
open: true
})
)
}
return config
})