-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
46 lines (40 loc) · 1.15 KB
/
vite.config.ts
File metadata and controls
46 lines (40 loc) · 1.15 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
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'
import alias from '@rollup/plugin-alias'
import path from 'path'
import { defineConfig } from 'vite'
// import liveReload from 'vite-plugin-live-reload'
import { v4wp } from '@kucrut/vite-for-wp'
export default defineConfig({
server: {
port: 5174,
cors: {
origin: '*',
preflightContinue: true,
},
headers: {
'Access-Control-Allow-Private-Network': 'true',
},
fs: {
allow: ['./'],
},
},
plugins: [
alias(),
react(),
tsconfigPaths(),
// liveReload(__dirname + '/**/*.php'), // Optional, if you want to reload page on php changed
v4wp({
input: 'js/src/main.tsx', // Optional, defaults to 'src/main.js'.
outDir: 'js/dist', // Optional, defaults to 'dist'.
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'js/src'),
// 把 @wordpress/i18n 的 import 導向本地 shim,讓 __()/sprintf() 直接使用 window.wp.i18n,
// 與 Bootstrap.php::inject_locale_data_to_handle() 注入的 setLocaleData 共用同一個 store。
'@wordpress/i18n': path.resolve(__dirname, 'js/src/shims/wordpress-i18n.ts'),
},
},
})