Last active
May 7, 2023 22:11
-
-
Save mpociot/1c2cfcdf90ca2175011ebeb60d4a0d54 to your computer and use it in GitHub Desktop.
Using Vite in combination with Valet's secured sites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defineConfig } from 'vite'; | |
import laravel from 'laravel-vite-plugin'; | |
import fs from 'fs'; | |
import { resolve } from 'path'; | |
import { homedir } from 'os'; | |
let host = 'sendstack.test'; | |
let homeDir = homedir(); | |
let serverConfig = {}; | |
if (homeDir) { | |
serverConfig = { | |
https: { | |
key: fs.readFileSync(resolve(homeDir, `.config/valet/Certificates/${host}.key`)), | |
cert: fs.readFileSync(resolve(homeDir, `.config/valet/Certificates/${host}.crt`)), | |
}, | |
hmr: { | |
host: 'sendstack.test', | |
}, | |
host: 'sendstack.test', | |
}; | |
} | |
export default defineConfig({ | |
plugins: [laravel([ | |
'resources/js/app.js' | |
])], | |
server: serverConfig, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use APP_URL from .env-file as host to prevent setting up the host in multiple files you can use vites loadEnv-method