-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
41 lines (39 loc) · 1.4 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
import laravel from 'laravel-vite-plugin'
import { defineConfig, loadEnv } from 'vite'
import { networkInterfaces } from 'os'
import VitePluginBrowserSync from 'vite-plugin-browser-sync'
/** @type {import('vite').UserConfig} */
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const ip = Object.values(networkInterfaces()).flat().find((i) => i.family == 'IPv4' && !i.internal)?.address
const useBrowsersync = env.VITE_BROWSERSYNC && ip
return {
plugins: [
laravel({
refresh: true,
valetTls: env.APP_URL.startsWith('https://') ? env.APP_URL.replace(/^https?:\/\//, '') : false,
input: [
'resources/css/site.css',
'resources/js/site.js',
'resources/js/home.js',
'resources/js/utility_page.js',
]
}),
(() => {
if (useBrowsersync) {
return VitePluginBrowserSync({
bs: {
proxy: env.APP_URL,
notify: false,
open: 'external',
},
})
}
})(),
],
server: {
host: useBrowsersync ? ip : false,
open: env.APP_URL
}
}
});