-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
63 lines (59 loc) · 1.8 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 } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import { createHtmlPlugin } from "vite-plugin-html";
// https://vitejs.dev/config/
const baseUrl = process.env.NODE_ENV === "production" ? "/vue-composition-demo/" : "/";
const INVALID_CHAR_REGEX = /[\u0000-\u001F"#$&*+,:;<=>?[\]^`{|}\u007F]/g;
const DRIVE_LETTER_REGEX = /^[a-z]:/i;
export default defineConfig({
base: baseUrl,
build: {
outDir: "dist",
rollupOptions: {
output: {
sanitizeFileName(fileName) {
const match = DRIVE_LETTER_REGEX.exec(fileName);
const driveLetter = match ? match[0] : "";
// A `:` is only allowed as part of a windows drive letter (ex: C:\foo)
// Otherwise, avoid them because they can refer to NTFS alternate data streams.
return driveLetter + fileName.slice(driveLetter.length).replace(INVALID_CHAR_REGEX, "");
},
},
},
},
plugins: [
vue(),
createHtmlPlugin({
minify: false,
inject: {
data: {
title: "VueCompositionDemo",
// injectScript: `<script type="module" src="${baseUrl}catch-script-load-error.js"></script>`,
},
// tags: [
// {
// tag: "script",
// injectTo: "head",
// attrs: {
// src: "https://lzt.com/vue@3.2.47/dist/vue.global.prod.js",
// },
// },
// {
// tag: "script",
// injectTo: "head",
// attrs: {
// src: "https://lzt.com/naive-ui@2.34.3/dist/index.prod.js",
// },
// },
// ],
},
}),
],
// 配置别名
resolve: {
alias: {
"@": resolve(__dirname, "src"),
},
},
});