-
Notifications
You must be signed in to change notification settings - Fork 6
/
vite.config.js
48 lines (43 loc) · 1.49 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
import { defineConfig, loadEnv } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
const isOpen = process.env.IS_OPEN === 'true';
const buildDir = isOpen ? 'build_open' : 'build';
const _dirname = dirname(fileURLToPath(import.meta.url));
export default ({ mode }) => {
const env = loadEnv(mode, process.cwd(), 'VITE_');
const config = {
plugins: [
laravel([
isOpen ? 'resources/js/open.js' : 'resources/js/app.js',
'resources/sass/app.scss',
'resources/sass/app-dark_unrounded.scss',
]),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
build: {
manifest: isOpen ? 'manifest.open.json' : 'manifest.json',
outDir: `public/${buildDir}`,
},
resolve: {
alias: {
'@': resolve(_dirname, './resources/js/'),
'%store': resolve(_dirname, './resources/js/bootstrap/store.js'),
'%router': resolve(_dirname, './resources/js/bootstrap/router.js'),
},
},
};
if(env.VITE_APP_PATH) {
config.base = `${env.VITE_APP_PATH.replace(/\/$/, '')}/${buildDir}/`;
}
return defineConfig(config);
};