Hey 👋
I made a decision to create a brand new venture at this time, then I created a brand new laravel venture and it is coming with a brand new belongings compiler, vite.
However my venture requires SSL in native growth, then I wanted to make the vite works along with SSL and laravel valet.
I didn’t discover a lot content material on the web about it, as a result of it is a very new launch, then I made a decision to share the answer with you.
Let’s go, first guarantee your area have already got SSL with the command:
cd ~/Code/your-current-project
valet safe your-current-project
Now examine within the browser your area it is working with the certificates.
Resolution
The magic is you go the important thing and cert to vite.config.js as you make in Nginx or Apache.
Examine the file instance bellow 👇
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
const area = "area.take a look at"; // add it
const homedir = require("os").homedir(); // add it
export default defineConfig({
plugins: [
laravel({
input: "resources/js/app.js",
ssr: "resources/js/ssr.js",
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
// add this block
server: {
https: {
key: homedir + "/.config/valet/Certificates/" + area + ".key",
cert: homedir + "/.config/valet/Certificates/" + area + ".crt",
},
host: area,
hmr: {
host: area,
},
},
});
I hope this text helped you!