-
Notifications
You must be signed in to change notification settings - Fork 20
/
vite.config.common.js
75 lines (68 loc) · 1.69 KB
/
vite.config.common.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import laravel from "laravel-vite-plugin";
import vue from "@vitejs/plugin-vue";
import * as fs from "fs";
import Components from "unplugin-vue-components/vite";
import { PrimeVueResolver } from "@primevue/auto-import-resolver";
import { loadEnv } from "vite";
export default (mode) => {
const ENV_PREFIX = ["VITE_"];
process.env = { ...process.env, ...loadEnv(mode, process.cwd(), ENV_PREFIX) };
const VITE_HMR_HOST = process.env.VITE_HOST || "localhost";
const VITE_PORT = parseInt(process.env.VITE_PORT || 1073);
return {
plugins: [
laravel({
input: ["resources/js/app.js", "resources/sass/app.scss"],
}),
vue(),
Components({
dirs: ["resources/js", "resources/custom/js"],
allowOverrides: true,
extensions: ["vue"],
deep: true,
dts: true,
resolvers: [PrimeVueResolver()],
}),
],
build: {
rollupOptions: {
output: {
manualChunks: (path) => {
if (path.includes("node_modules")) {
return "vendor";
}
return "app";
},
},
},
},
server: {
https: getSslConfig(process.env),
host: "0.0.0.0",
port: VITE_PORT,
strictPort: true,
hmr: {
host: VITE_HMR_HOST,
},
},
optimizeDeps: {
include: ["axe-core"],
},
css: {
preprocessorOptions: {
scss: {
silenceDeprecations: ["import", "global-builtin"],
},
},
},
};
};
function getSslConfig(env) {
if (env.VITE_SSL !== "true") {
return false;
}
return {
key: fs.readFileSync("ssl/privkey.pem"),
cert: fs.readFileSync("ssl/fullchain.pem"),
};
}