-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
57 lines (50 loc) · 1.32 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
54
55
56
57
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// import legacy from '@vitejs/plugin-legacy'
import liveReload from 'vite-plugin-live-reload'
const { resolve, basename } = require('path')
const themeDir = resolve(__dirname, './')
const themeUrl = `/wp-content/themes/${basename(__dirname)}`
export default defineConfig({
plugins: [
vue(),
liveReload(themeDir+'/**/*.php')
],
root: 'src',
base: themeUrl + (process.env.NODE_ENV === 'production' ? '/dist/' : '/src/'),
build: {
// output dir for production build
outDir: themeDir + '/dist',
emptyOutDir: true,
// emit manifest so PHP can find the hashed files
manifest: true,
// esbuild target
target: 'es2018',
rollupOptions: {
input: '/app.js'
}
},
server: {
// required to load scripts from custom host
cors: true,
// we need a strict port to match on PHP side
//
strictPort: true,
port: 3000
// if changed match here /templates/html/vite.php
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "./src/scss/_global.scss";`
},
},
},
// required for in-browser template compilation
// https://v3.vuejs.org/guide/installation.html#with-a-bundler
resolve: {
alias: {
vue: 'vue/dist/vue.esm-bundler.js'
}
}
})