forked from vinkla/wordplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
43 lines (42 loc) · 1.11 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
42
43
import {defineConfig} from 'vite';
require('dotenv').config();
export default defineConfig(() => ({
publicDir: 'resources/static',
server: {
origin: 'http://localhost:5173',
},
base: '',
build: {
assetsDir: '',
emptyOutDir: true,
manifest: true,
outDir: `public/themes/${process.env.WP_DEFAULT_THEME}/assets`,
rollupOptions: {
input: 'resources/js/index.js',
output: {
assetFileNames: (assetInfo) => {
const info = assetInfo.name.split('.');
let extType = info[info.length - 1];
if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(extType)) {
extType = 'img';
} else if (/woff|woff2|eot|ttf/.test(extType)) {
extType = 'css';
}
return `${extType}/[name]-[hash][extname]`;
},
chunkFileNames: 'js/[name]-[hash].js',
entryFileNames: 'js/[name]-[hash].js',
},
},
},
plugins: [
{
name: 'php',
handleHotUpdate ({file, server}) {
if (file.endsWith('.php')) {
server.ws.send({type: 'full-reload', path: '*'});
}
},
}
]
}));