-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.js
93 lines (89 loc) · 2.39 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
92
93
import { fileURLToPath } from 'url';
import { defineConfig, loadEnv } from 'vite';
import Vue from '@vitejs/plugin-vue';
import { quasar as Quasar, transformAssetUrls } from '@quasar/vite-plugin';
import Eslint from 'vite-plugin-eslint';
import Pages from 'vite-plugin-pages';
import Layouts from 'vite-plugin-vue-layouts';
import SvgLoader from 'vite-svg-loader';
import Legacy from '@vitejs/plugin-legacy';
import Inspect from 'vite-plugin-inspect';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, '.');
return {
base: env.VITE_BASE_PUBLIC_PATH ?? '/',
plugins: [
Vue({
template: { transformAssetUrls }
}),
Quasar({
autoImportComponentCase: 'pascal',
sassVariables: false
}),
Eslint({
cache: false,
exclude: ['dist']
}),
Pages({
extensions: ['vue'],
pagesDir: [{ dir: 'src/modules/**/pages', baseRoute: '' }]
}),
Layouts({
defaultLayout: 'Default.layout',
layoutsDirs: 'src/shared/layouts'
}),
SvgLoader(),
Legacy({
targets: [
'> 1%',
'last 2 versions',
'not dead',
'chrome >= 77',
'safari >= 13',
'ios_saf >= 13'
]
}),
Inspect({
// change this to enable inspect for debugging
enabled: false
})
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
css: {
preprocessorOptions: {
scss: {
additionalData: `
@use 'src/styles/base/color';
@use 'src/styles/base/typography';
@use 'src/styles/utils/breakpoint';
`
}
}
},
build: {
rollupOptions: {
output: {
// https://rollupjs.org/guide/en/#outputmanualchunks
manualChunks(id) {
// 同 modules 內的檔案打包成同一個 chunk,
// 例如:src/modules/users 目錄內的檔案都被打包至 `users` chunk
const matched = id.match(/src\/modules\/(?<module>[^/]+?)\//);
const matchedModule = matched?.groups.module;
if (matchedModule) return matchedModule;
}
}
},
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
}
}
};
});