-
Notifications
You must be signed in to change notification settings - Fork 84
/
vite.config.js
70 lines (66 loc) · 1.64 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
import { defineConfig, loadEnv } from 'vite'
import autoprefixer from 'autoprefixer'
import flynt from './vite-plugin-flynt'
import globImporter from 'node-sass-glob-importer'
import FullReload from 'vite-plugin-full-reload'
import fs from 'fs'
const wordpressHost = 'http://localhost:3000'
const dest = './dist'
const entries = [
'./assets/admin.js',
'./assets/admin.scss',
'./assets/main.js',
'./assets/main.scss',
'./assets/print.scss',
'./assets/editor-style.scss'
]
const watchFiles = [
'*.php',
'templates/**/*',
'lib/**/*',
'inc/**/*',
'./Components/**/*.{php,twig}'
]
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const host = env.VITE_DEV_SERVER_HOST || wordpressHost
const isSecure = host.indexOf('https://') === 0 && (env.VITE_DEV_SERVER_KEY || env.VITE_DEV_SERVER_CERT)
return {
base: './',
css: {
devSourcemap: true,
preprocessorOptions: {
scss: {
importer: globImporter()
}
},
postcss: {
plugins: [autoprefixer()]
}
},
resolve: {
alias: {
'@': __dirname
}
},
plugins: [flynt({ dest, host }), FullReload(watchFiles)],
server: {
https: isSecure
? {
key: fs.readFileSync(env.VITE_DEV_SERVER_KEY),
cert: fs.readFileSync(env.VITE_DEV_SERVER_CERT)
}
: false,
host: 'localhost' // preserve conflicts with IpV6
},
build: {
// generate manifest.json in outDir
manifest: true,
outDir: dest,
rollupOptions: {
// overwrite default .html entry
input: entries
}
}
}
})