generated from blonestar/wp-theme-vite-tailwind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
104 lines (82 loc) · 2.56 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// View your website at your own local server
// for example http://vite-php-setup.test
// http://localhost:3000 is serving Vite on development
// but accessing it directly will be empty
// IMPORTANT image urls in CSS works fine
// BUT you need to create a symlink on dev server to map this folder during dev:
// ln -s {path_to_vite}/src/assets {path_to_public_html}/assets
// on production everything will work just fine
//import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
import liveReload from 'vite-plugin-live-reload'
const { resolve } = require('path')
const fs = require('fs')
// https://vitejs.dev/config
export default defineConfig({
plugins: [
//vue(),
liveReload(__dirname+'/**/*.php')
],
// config
root: '',
base: process.env.NODE_ENV === 'development'
? '/'
: '/dist/',
build: {
// output dir for production build
outDir: resolve(__dirname, './dist'),
emptyOutDir: true,
// emit manifest so PHP can find the hashed files
manifest: true,
// esbuild target
target: 'es2018',
// our entry
rollupOptions: {
input: {
main: resolve( __dirname + '/main.js')
},
/*
output: {
entryFileNames: `[name].js`,
chunkFileNames: `[name].js`,
assetFileNames: `[name].[ext]`
}*/
},
// minifying switch
minify: true,
write: true
},
server: {
// required to load scripts from custom host
cors: true,
// we need a strict port to match on PHP side
// change freely, but update in your functions.php to match the same port
strictPort: true,
port: 3000,
// serve over http
https: false,
// serve over httpS
// to generate localhost certificate follow the link:
// https://github.com/FiloSottile/mkcert - Windows, MacOS and Linux supported - Browsers Chrome, Chromium and Firefox (FF MacOS and Linux only)
// installation example on Windows 10:
// > choco install mkcert (this will install mkcert)
// > mkcert -install (global one time install)
// > mkcert localhost (in project folder files localhost-key.pem & localhost.pem will be created)
// uncomment below to enable https
//https: {
// key: fs.readFileSync('localhost-key.pem'),
// cert: fs.readFileSync('localhost.pem'),
//},
hmr: {
host: 'localhost',
//port: 443
},
},
// 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'
}
}
})