-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
91 lines (75 loc) · 2.47 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
89
90
91
import path from 'path';
// Vite Plugins
import VuePlugin from '@vitejs/plugin-vue';
import EslintPlugin from 'vite-plugin-eslint';
import CompressionPlugin from 'vite-plugin-compression';
// Rollup Plugins
import { nodeResolve } from '@rollup/plugin-node-resolve';
import AnalyzePlugin from 'rollup-plugin-analyzer';
export default ({ command }) => ({
// Set the root to our source folder
root: './src/web/assets',
// When building update the destination base
base: command === 'serve' ? '' : '/dist/',
build: {
outDir: 'app/dist',
emptyOutDir: true,
manifest: true,
sourcemap: true,
rollupOptions: {
input: {
zen: '/app/src/js/zen.js',
},
},
},
server: {
origin: 'http://localhost:4030',
hmr: {
// Using the default `wss` doesn't work on https
protocol: 'ws',
},
},
plugins: [
// Keep JS looking good with eslint
// https://github.com/gxmari007/vite-plugin-eslint
EslintPlugin({
cache: false,
fix: true,
include: './src/web/assets/**/*.{js,vue}',
exclude: './src/web/assets/app/src/js/vendor/**/*.{js,vue}',
}),
// Vue 3 support
// https://github.com/vitejs/vite/tree/main/packages/plugin-vue
VuePlugin(),
// Analyze bundle size
// https://github.com/doesdev/rollup-plugin-analyzer
AnalyzePlugin({
summaryOnly: true,
limit: 15,
}),
// Gzip assets
// https://github.com/vbenjs/vite-plugin-compression
CompressionPlugin({
filter: /\.(js|mjs|json|css|map)$/i,
}),
],
resolve: {
alias: {
// // Allow us to use `@/` in JS, CSS and Twig for ease of development.
'@': path.resolve('./src/web/assets/app/src'),
// Allow us to use `@utils/` in JS for misc utilities.
'@utils': path.resolve('./src/web/assets/app/src/js/utils'),
// Allow us to use `@components/` in Vue components.
'@components': path.resolve('./src/web/assets/app/src/js/components'),
// Vue 3 doesn't support the template compiler out of the box
'vue': 'vue/dist/vue.esm-bundler.js',
},
},
// Add in any components to optimise them early.
optimizeDeps: {
include: [
'lodash-es',
'vue',
],
},
});