-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
72 lines (68 loc) · 2.03 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
import { defineConfig, loadEnv } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import fs from 'fs';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
if (mode === 'production') {
// No need to define `server` for production; skip HMR and host configuration
return {
plugins: [
laravel({
input: 'resources/js/app.js',
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
};
}
// Development server configuration
const isValet = env.APP_ENV === 'valet';
const serverConfig = isValet ? {
host: 'arbor.test',
port: 5173,
https: {
key: fs.readFileSync(path.resolve(env.HOME, '.config/valet/Certificates/arbor.test.key')),
cert: fs.readFileSync(path.resolve(env.HOME, '.config/valet/Certificates/arbor.test.crt')),
},
hmr: {
protocol: 'wss',
host: 'arbor.test',
port: 5173,
},
} : {
host: 'arbor.test',
port: 5173,
https: env.APP_ENV !== 'lima', // HTTPS for non-Lima environments
hmr: {
protocol: env.APP_ENV === 'lima' ? 'ws' : 'wss',
host: 'arbor.test',
port: 5173,
},
};
return {
plugins: [
laravel({
input: 'resources/js/app.js',
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
server: serverConfig,
};
});