-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.ts
55 lines (55 loc) · 1.79 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 } from "vite"
import vue from "@vitejs/plugin-vue"
import path from "path"
import visualizer from "rollup-plugin-visualizer"
import ViteComponents from "unplugin-vue-components/vite"
import PrerenderSpaPlugin from "prerender-spa-plugin"
import svgSpritePlugin from "vite-plugin-svg-sprite-component"
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue({
script: {
refSugar: true,
},
}),
ViteComponents({ directoryAsNamespace: true }),
visualizer({
filename: "./dist/stats.html",
template: "sunburst",
gzipSize: true,
}),
PrerenderSpaPlugin({
// Absolute path to compiled SPA
staticDir: path.resolve(__dirname, "./dist"),
indexPath: path.resolve(__dirname, "./dist/index.html"),
// List of routes to prerender
routes: ["*"],
// Options
postProcess(context) {
const titles = {
"/": "Home",
"/explore": "Explore",
"/portfolio": "Portfolio",
}
context.html = context.html.replace(/<title>[^<]*<\/title>/i, `<title>${titles[context.route]}</title>`)
return context
},
}),
svgSpritePlugin({ symbolId: (name) => "icon-" + name, component: { type: "vue", defaultExport: true } }),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
extensions: [".js", ".vue", ".json", ".ts", ".png", ".svg"],
},
define: {
"process.env": process.env,
},
optimizeDeps: {
include: ["color"],
// @ts-ignore
allowNodeBuiltins: ["stream"],
},
})