-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.js
More file actions
73 lines (69 loc) · 2.42 KB
/
Copy pathvite.config.js
File metadata and controls
73 lines (69 loc) · 2.42 KB
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
import { defineConfig } from 'vite';
import path from 'node:path';
const THEME_NAME = 'backend';
const SRC_ROOT = 'resources/backend';
const DEST_ROOT = 'webroot/backend';
export default defineConfig(({ command }) => ({
resolve: {
alias: {
'@': path.resolve(__dirname, `${SRC_ROOT}/scripts`)
}
},
base: command === 'build' ? `/${THEME_NAME}/` : '/',
// publicDir: `${SRC_ROOT}/public`,
server: {
proxy: {
// Exclude Vite internals and source/destination folders from proxy
[`^/(?!@vite|@fs|node_modules|${SRC_ROOT}|${DEST_ROOT}).*`]: {
target: 'http://bakekit.test',
changeOrigin: true,
},
},
host: true,
},
build: {
outDir: DEST_ROOT,
emptyOutDir: false,
minify: command === 'build' ? 'terser' : false,
rollupOptions: {
input: {
app: `${SRC_ROOT}/scripts/app.js`,
blocks: `${SRC_ROOT}/scripts/pages/blocks/blocks.js`,
menu: `${SRC_ROOT}/scripts/pages/blocks/menu.js`,
menus: `${SRC_ROOT}/scripts/pages/menus/menus.js`,
meta: `${SRC_ROOT}/scripts/pages/meta/meta.js`,
users: `${SRC_ROOT}/scripts/pages/users/users.js`,
},
output: {
entryFileNames: 'js/[name].js',
chunkFileNames: 'js/chunks/[name]-[hash].js',
assetFileNames: (assetInfo) => {
const name = assetInfo.names?.[0] ?? '';
if (/\.(css|scss|sass)$/.test(name)) return 'css/app.[ext]';
if (/\.(woff2?|ttf|eot|otf)$/.test(name)) return 'fonts/[name][extname]';
if (/\.(png|jpe?g|gif|svg|webp|avif)$/.test(name)) return 'img/[name].[ext]';
return 'assets/[name].[ext]';
},
},
},
},
css: {
preprocessorOptions: {
scss: {
loadPaths: [
'node_modules',
`${SRC_ROOT}/styles`,
],
api: 'modern-compiler',
silenceDeprecations: [
'import',
'color-functions',
'global-builtin',
'legacy-js-api',
'slash-div',
'if-function'
],
}
}
}
}));