vite.config.cdn.ts
1.47 KB
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
import { loadEnv, mergeConfig } from "vite";
import baseConfig from "./vite.config.base";
import configCompressPlugin from "./plugin/compress";
import configVisualizerPlugin from "./plugin/visualizer";
import configArcoResolverPlugin from "./plugin/arcoResolver";
import configImageminPlugin from "./plugin/imagemin";
import VitePluginOss from "vite-plugin-oss";
const config = loadEnv("production", "");
const ossPath = `vendor/user/asset${new Date()
.toLocaleString("zh")
.slice(0, 20)
.replace(/[\s/:]/g, "")}`;
export default mergeConfig(
{
mode: "production",
base: config.VITE_OSS_HOST,
server: {
https: true
},
plugins: [
configCompressPlugin("gzip"),
configVisualizerPlugin(),
configArcoResolverPlugin(),
configImageminPlugin(),
VitePluginOss({
from: `./dist/${ossPath}/**`,
accessKeyId: config.VITE_OSS_ACCESS_KEY,
accessKeySecret: config.VITE_OSS_ACCESS_SECRET,
bucket: config.VITE_OSS_BUCKET,
region: config.VITE_OSS_REGION,
quitWpOnError: true,
deleteOrigin: true,
deleteEmptyDir: true
})
],
build: {
assetsDir: ossPath,
rollupOptions: {
output: {
manualChunks: {
arco: ["@arco-design/web-vue"],
chart: ["echarts", "vue-echarts"],
vue: ["vue", "vue-router", "pinia", "@vueuse/core", "vue-i18n"]
}
}
},
chunkSizeWarningLimit: 2000
}
},
baseConfig
);