Skip to content

Instantly share code, notes, and snippets.

@nasir-mandal
Created May 10, 2023 09:42
Show Gist options
  • Save nasir-mandal/1502b22f9680d3951448b5a7297680ae to your computer and use it in GitHub Desktop.
Save nasir-mandal/1502b22f9680d3951448b5a7297680ae to your computer and use it in GitHub Desktop.
Laravel vite.config.js for MAC OS ( Local development )
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import fs from 'fs';
import { homedir } from 'os';
import { resolve } from 'path';
// Ignore the protocol on the host, ie do not put "http"
const host = 'eduman-bdevs.test';
const viteServerConfig = host => {
let keyPath = resolve(homedir(), `.config/valet/Certificates/${host}.key`)
let certificatePath = resolve(homedir(), `.config/valet/Certificates/${host}.crt`)
if (!fs.existsSync(keyPath)) {
return {}
}
if (!fs.existsSync(certificatePath)) {
return {}
}
return {
hmr: {host},
host,
https: {
key: fs.readFileSync(keyPath),
cert: fs.readFileSync(certificatePath),
},
}
}
export default defineConfig({
build: {
outDir: './public/build/'
},
publicDir: "./public/build/",
server: viteServerConfig(host),
plugins: [
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js',
],
refresh: true,
}),
],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment