forked from qingwave/weave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
69 lines (66 loc) · 1.94 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
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import prismjs from "vite-plugin-prismjs";
import fs from 'fs'
// env must start with this prefix. in .env config
const envPrefix = 'WEAVE_';
// https://vitejs.dev/config/
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd(), envPrefix) };
return defineConfig({
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
'views': resolve(__dirname, 'src/views'),
'components': resolve(__dirname, 'src/components'),
}
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/styles/element.scss" as *;`,
},
},
},
plugins: [
vue(),
prismjs({
languages: ["json", "js", "go", "bash", "yaml", "markup"],
plugins: ["line-numbers"],
theme: "solarizedlight",
css: true,
}),
AutoImport({
resolvers: [ElementPlusResolver({ importStyle: "sass" })],
}),
Components({
resolvers: [
ElementPlusResolver({ importStyle: "sass" }),
],
})
],
envPrefix: envPrefix,
server: {
// if your frontend not in the localhost, please uncomment the https config meanwhile
host: process.env.WEAVE_HOST,
port: process.env.WEAVE_PORT,
// https: {
// ca: fs.readFileSync('../certs/root.crt'),
// key: fs.readFileSync('../certs/frontend.key'),
// cert: fs.readFileSync('../certs/frontend.crt')
// },
proxy: {
'/api': {
target: process.env.WEAVE_SERVER,
changeOrigin: true,
ws: true,
rewrite: (path) => path.replace(/\/api/, '/api')
}
},
}
});
}