-
Notifications
You must be signed in to change notification settings - Fork 10
/
vite.plugins.js
40 lines (35 loc) · 896 Bytes
/
vite.plugins.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
import { homedir } from 'os';
import { resolve } from 'path';
import fs from 'fs';
export let bladeRefreshPlugin = {
name: 'blade',
handleHotUpdate({ file, server }) {
if (file.endsWith('.blade.php')) {
server.ws.send({
type: 'full-reload',
path: '*',
});
}
},
};
export const serverConfiguration = (host) => {
const keyPath = resolve(
homedir(),
`.config/valet/Certificates/${host}.key`,
);
const certificatePath = resolve(
homedir(),
`.config/valet/Certificates/${host}.crt`,
);
if (!fs.existsSync(keyPath) || !fs.existsSync(certificatePath)) {
return {};
}
return {
hmr: { host },
host,
https: {
key: fs.readFileSync(keyPath),
cert: fs.readFileSync(certificatePath),
},
};
};