-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
55 lines (52 loc) · 1.43 KB
/
vite.config.ts
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
import { defineConfig, loadEnv } from "vite";
import path from "path";
import vueJsx from "@vitejs/plugin-vue-jsx";
import mkcert from "vite-plugin-mkcert";
import createVitePlugins from "./vite/plugins";
// https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd());
const { VITE_APP_ENV } = env;
return {
base:
process.env.NODE_ENV === "production"
? process.env.FX_CDN_PUBLIC_PATH
: "/",
resolve: {
// https://cn.vitejs.dev/config/#resolve-alias
alias: {
// 设置路径
"~": path.resolve(__dirname, "./"),
// 设置别名
"@": path.resolve(__dirname, "./src"),
vue: "vue/dist/vue.esm-bundler.js",
},
// https://cn.vitejs.dev/config/#resolve-extensions
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json"],
},
css: {
preprocessorOptions: {
less: {
modifyVars: {
hack: `true; @import (reference) "${path.resolve(
"src/assets/styles/variables.less"
)}";`,
},
javascriptEnabled: true,
},
},
},
experimental: {
renderBuiltUrl(filename, type) {
return {
relative: true,
};
},
},
server: {
https: true,
host: "0.0.0.0",
},
plugins: [vueJsx(), mkcert(), createVitePlugins(env, command === "build")],
};
});