forked from hellof2e/quark-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
102 lines (99 loc) · 2.12 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import react from "@vitejs/plugin-react";
import legacy from "@vitejs/plugin-legacy";
import Markdown from "vite-plugin-md";
import cssVariable from "@quarkd/rollup-plugin-css-variable";
import typescript from "@rollup/plugin-typescript";
import reloadOnChange from "vite-plugin-full-reload";
import path from "path";
import variableMap from "./global-css";
// https://highlightjs.org/
const hljs = require("highlight.js");
const { resolve } = path;
const plugins = [
// 监听 css 变化热更新
reloadOnChange(["../packages/quarkd/src/**/*.css"]),
cssVariable({
variableMap,
prefix: "quark-",
}),
vue({
include: [/\.vue$/, /\.md$/],
template: {
compilerOptions: {
isCustomElement: (tag) => tag.startsWith("quark-"),
},
},
}),
typescript(),
Markdown({
// default options passed to markdown-it
// see: https://markdown-it.github.io/markdown-it/
markdownItOptions: {
highlight(str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value;
} catch (__) {}
}
return ""; // 使用额外的默认转义
},
},
}),
legacy({
targets: ["defaults", "not IE 11"],
}),
react({
jsxRuntime: "classic",
babel: {
// presets: [['@babel/preset-env'], ['@babel/preset-typescript']],
plugins: [
[
"@babel/plugin-proposal-decorators",
{
legacy: true,
},
],
"@babel/plugin-proposal-class-properties",
],
},
}),
];
// https://vitejs.dev/config/
const rootPtah = resolve(__dirname, "../");
export default defineConfig({
root: rootPtah,
base: "./",
server: {
port: 2022,
host: "0.0.0.0",
},
resolve: {
alias: [
{ find: "@", replacement: resolve(__dirname, "./src") },
{
find: "@quarkd/quark",
replacement: resolve(__dirname, "../packages/quarkd"),
},
],
},
plugins,
// 打包配置
build: {
target: "es2015",
outDir: "dist",
cssCodeSplit: true,
rollupOptions: {
input: {
mobile: resolve(__dirname, "../demo.html"),
},
},
minify: false,
},
esbuild: {
define: {
this: "window",
},
},
});