-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
62 lines (57 loc) · 1.54 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
56
57
58
59
60
61
62
import { defineConfig, loadEnv } from "vite";
import Components from "unplugin-vue-components/vite";
import { VuetifyResolver } from "unplugin-vue-components/resolvers";
import vue from "@vitejs/plugin-vue2";
import viteCompression from "vite-plugin-compression";
import { resolve } from "path";
import dayjs from "dayjs";
import pkg from "./package.json";
import { viteSingleFile } from "vite-plugin-singlefile";
import { VitePluginFonts } from "vite-plugin-fonts";
const OUTPUT_DIR = "dist";
const root = process.cwd();
const { dependencies, devDependencies, name, version } = pkg;
const __APP_INFO__ = {
pkg: { dependencies, devDependencies, name, version },
lastBuildTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
};
/** @type {import('vite').UserConfig} */
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
return defineConfig({
base: process.env.VITE_APP_PUBLIC_PATH,
root,
resolve: {
alias: [
{
find: "@",
replacement: resolve(__dirname, "src"),
},
],
},
plugins: [
vue(),
Components({
resolvers: [VuetifyResolver()],
}),
viteCompression({
algorithm: "gzip",
}),
viteSingleFile(),
VitePluginFonts({
google: {
families: ["Lato"],
},
}),
],
server: {
port: process.env.VITE_APP_PORT || 3000,
},
build: {
target: "es2015",
cssTarget: "chrome80",
outDir: OUTPUT_DIR,
chunkSizeWarningLimit: 2000,
},
});
};