-
Notifications
You must be signed in to change notification settings - Fork 182
/
vite.config.js
64 lines (59 loc) · 1.82 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
import { defineConfig, loadEnv } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import DefineOptions from 'unplugin-vue-define-options/vite'
import fs from 'fs';
import { resolve } from 'path';
import { homedir } from 'os';
export default defineConfig(({command, mode}) => {
// Load current .env-file
const env = loadEnv(mode, process.cwd(), '')
// Set the host based on APP_URL
let host = env.APP_URL !== undefined ? new URL(env.APP_URL).host : null;
let homeDir = homedir()
let serverConfig = {}
if (host && homeDir) {
const certificatesPath = env.CERTIFICATES_PATH !== undefined ? env.CERTIFICATES_PATH : `.config/valet/Certificates/${host}`;
serverConfig = {
https: {
key: fs.readFileSync(
resolve(homeDir, `${certificatesPath}.key`),
),
cert: fs.readFileSync(
resolve(homeDir, `${certificatesPath}.crt`),
),
},
hmr: {
host
},
host
}
}
return {
publicDir: 'vendor/mixpost',
plugins: [
laravel({
input: 'resources/js/app.js',
publicDirectory: 'resources/dist',
buildDirectory: 'vendor/mixpost',
refresh: true
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
DefineOptions()
],
resolve: {
alias: {
'@css': '/resources/css',
'@img': 'resources/img'
},
},
server: serverConfig
}
});