-
Notifications
You must be signed in to change notification settings - Fork 13
/
vite.config.js
53 lines (51 loc) · 1.52 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
44
45
46
47
48
49
50
51
52
53
import { resolve } from 'path'
import { defineConfig } from 'vite'
import legacy from '@vitejs/plugin-legacy'
import basicSsl from '@vitejs/plugin-basic-ssl'
import liveReload from 'vite-plugin-live-reload'
import getThemeDir from './js-helpers/getThemeDir.mjs'
// https://vitejs.dev/config/
export const viteConfig = {
// custom cache dir for vite
cacheDir: './node_modules/.vite/press-wind',
// plugins : ssl, live reload, legacy
plugins: [basicSsl(), liveReload([`${__dirname}+ "/**/*.php`]), legacy({})],
base:
process.env.APP_ENV === 'development'
? `/wp-content/themes/${getThemeDir()}/`
: `/wp-content/themes/${getThemeDir()}/dist/`,
root: '',
// you can use lightningcss for minify css only if you don't use tailwindcss
// css: {
// transformer: "lightningcss",
// lightningcss: {
// targets: browserslistToTargets(browserslist(">= 0.25%")),
// },
// },
build: {
cssCodeSplit: true,
cssMinify: 'lightningcss',
// output dir for production build
outDir: resolve(__dirname, 'dist'),
emptyOutDir: true,
// required for load assets
manifest: true,
rollupOptions: {
input: resolve(__dirname, 'main.js'),
},
},
server: {
cors: true,
strictPort: true,
// port for dev server, you can change it if you want but you need to change the port in the function.php too
port: 3000,
// use ssl
https: true,
// hot module replacement port
hmr: {
protocol: 'wss',
port: 3000,
},
},
}
export default defineConfig(viteConfig)