forked from AzuraCast/AzuraCast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
98 lines (89 loc) · 2.9 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
94
95
96
97
98
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {glob} from "glob";
import {resolve} from "path";
import eslint from "vite-plugin-eslint";
const inputs = glob.sync('./frontend/js/pages/**/*.js').reduce((acc, path) => {
// vue/pages/Admin/Index becomes AdminIndex
const entry = path.replace(/\.js$/g, '')
.replace(/^frontend\/js\/pages\//g, '')
.replace(/\//g, '');
acc[entry] = resolve(__dirname, path)
return acc
}, {});
inputs['Layout'] = resolve(__dirname, './frontend/js/layout.js');
console.log(inputs);
// https://vitejs.dev/config/
export default defineConfig({
root: resolve(__dirname, './frontend/'),
base: '/static/vite_dist',
build: {
rollupOptions: {
input: inputs,
output: {
manualChunks: {
vue: ['vue'],
lodash: ['lodash'],
leaflet: ['leaflet'],
hlsjs: ['hls.js'],
zxcvbn: ['zxcvbn']
},
chunkFileNames: (assetInfo) => {
if (assetInfo.name) {
if (assetInfo.name === 'translations') {
const translationParts = assetInfo.facadeModuleId
.split('/');
const translationPath = translationParts[translationParts.length - 2];
return `translations-${translationPath}-[hash:8].js`
}
const assetName = assetInfo.name.replace(
'.vue_vue_type_style_index_0_lang',
''
).replace(
'.vue_vue_type_script_setup_true_lang',
''
);
return `${assetName}-[hash:8].js`;
}
return '[name]-[hash:8].js';
}
}
},
manifest: true,
emptyOutDir: true,
chunkSizeWarningLimit: '1m',
outDir: resolve(__dirname, './web/static/vite_dist')
},
css: {
preprocessorOptions: {
scss: {
quietDeps: true,
silenceDeprecations: ['legacy-js-api']
}
}
},
server: {
strictPort: true,
host: true,
fs: {
allow: [
resolve(__dirname, './frontend/'),
resolve(__dirname, './node_modules/'),
resolve(__dirname, './translations/')
]
}
},
resolve: {
alias: {
'!': resolve(__dirname, '.'),
'~': resolve(__dirname, './frontend')
},
extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
plugins: [
vue(),
eslint({
fix: true
})
],
})