-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
80 lines (75 loc) · 2.35 KB
/
vite.config.ts
File metadata and controls
80 lines (75 loc) · 2.35 KB
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
76
77
78
79
80
import fs from 'node:fs';
import path from 'node:path';
import tailwindcss from "@tailwindcss/vite";
import vue from '@vitejs/plugin-vue';
import dotenv from 'dotenv';
import laravel from 'laravel-vite-plugin';
import i18n from 'laravel-vue-i18n/vite';
import { defineConfig } from 'vite';
const base = __dirname;
const theme = path.basename(__dirname);
// https://vitejs.dev/config/
export default defineConfig(() => {
const envPath = path.resolve(__dirname, '.env')
if (fs.existsSync(envPath)) {
console.log(envPath);
dotenv.config({ path: envPath })
}
function env(key: string, defaultValue: unknown = null) {
if (key in process.env) {
return process.env[key];
} else {
return defaultValue;
}
}
const base = __dirname;
const theme = path.basename(__dirname);
return {
base: `/themes/${theme}/assets/`,
publicDir: path.resolve(__dirname, 'resources/assets'),
plugins: [
laravel({
input: [
'resources/theme.ts'
],
hotFile: path.join(base, 'assets', '.hot'),
refresh: {
paths: [
'./**/*',
'../../plugins/ratmd/laika/resources/**/*'
]
},
}),
tailwindcss(),
vue(),
i18n(),
],
build: {
manifest: true,
outDir: './assets/',
rollupOptions: {
output: {
manualChunks: (id) => id.includes('node_modules') ? 'vendor' : void 0
},
}
},
resolve: {
alias: {
'@': path.resolve(__dirname, './resources'),
'@laika': path.resolve(__dirname, '../../plugins/ratmd/laika/resources'),
}
},
server: {
cors: true,
host: env('VITE_HOST', '0.0.0.0'),
hmr: {
host: env('VITE_HOST', '0.0.0.0'),
},
allowedHosts: env('VITE_HOST', null) ? [ env('VITE_HOST') ] : [],
https: env('VITE_HTTPS', false) ? {
key: fs.readFileSync(env('VITE_HTTPS_KEY')),
cert: fs.readFileSync(env('VITE_HTTPS_CERT')),
}: void 0
}
};
});