-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvite.config.ts
53 lines (50 loc) · 1.52 KB
/
vite.config.ts
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
import path from "path";
import { defineConfig, PluginOption } from "vite";
import laravel from "laravel-vite-plugin";
import { watch } from "vite-plugin-watch";
import react from "@vitejs/plugin-react";
import svgr from "vite-plugin-svgr";
import { parseAll } from "./resources/js/I18n/loader";
import markdown from "@vavt/vite-plugin-import-markdown";
const buildTranslations = (inputPath: string, outputPath: string): PluginOption => {
let files: { name: string; path: string }[] = [];
return {
name: "i18n",
enforce: "post",
config(config) {
files = parseAll(inputPath, outputPath);
},
handleHotUpdate(context) {
if (/lang\/.*\.php$/.test(context.file)) {
files = parseAll(inputPath, outputPath);
}
},
};
};
export default defineConfig({
define: {
"process.env": {},
},
plugins: [
buildTranslations("lang", "resources/js/I18n/Locales"),
laravel({
input: "resources/js/app.tsx",
refresh: true,
}),
process.env.NODE_ENV !== "production"
? watch({
pattern: "app/{Data,Enums}/**/*.php",
command: "npm run generate:typescript",
})
: null,
react(),
svgr(),
markdown(),
],
resolve: {
alias: {
"@icons": path.resolve(__dirname, "./resources/icons/"),
"@images": path.resolve(__dirname, "./resources/images/"),
},
},
});