-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
89 lines (82 loc) · 2.06 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
import { resolve } from "node:path";
import { defineConfig, PluginOption } from 'vite'
import htmlPurge from 'vite-plugin-purgecss'
import vue from '@vitejs/plugin-vue'
import type { UserConfig } from 'vite';
// Node DNS prefers ipv6, this messes with the proxy server.
// workaround: change dns to prefer ipv4
import dns from 'node:dns';
dns.setDefaultResultOrder('ipv4first');
const htmlPurgeOptions = {
content: [ `./public/**/*.html`, `./src/**/*.vue`, `./src/**/*.ts` ],
defaultExtractor (content: any) {
const contentWithoutStyleBlocks = content.replace(/<style[^]+?<\/style>/gi, '')
return contentWithoutStyleBlocks.match(/[A-Za-z0-9-_/:]*[A-Za-z0-9-_/]+/g) || []
},
safelist: [
/-(leave|enter|appear)(|-(to|from|active))$/,
/^(?!(|.*?:)cursor-move).+-move$/,
/^router-link(|-exact)-active$/,
/data-v-.*/,
/leaflet-*/,
/marker-cluster*/,
/uplot*/,
/^u-*/,
/^dp*/
]
}
const devConfig: UserConfig = {
base: "/",
build: {}
};
const prodConfig: UserConfig = {
base: "/static/monitor-map/",
build: {
outDir: resolve(__dirname, "./dist"),
rollupOptions: {
input: {
sjvairMonitorMap: resolve(__dirname, "./src/main.ts")
},
output: {
entryFileNames: "[name].js",
assetFileNames: "[name].[ext]"
}
}
}
};
const devMode = process.env.PROD !== "true";
const { base, build }: UserConfig = devMode ? devConfig : prodConfig;
// https://vitejs.dev/config/
export default defineConfig({
// Base directory compiled files will be served from
base,
build: {
sourcemap: devMode,
minify: "terser",
...build
},
plugins: [
htmlPurge(htmlPurgeOptions) as unknown as PluginOption,
vue()
],
css: {
preprocessorOptions: {
scss: {
additionalData: `
$pantone-blue-light: #3549B6;
$sjvair-main: rgb(62, 142, 208);
@use "bulma/bulma";
`
},
}
},
server: {
proxy: {
"/api/1.0": {
target: "http://localhost:8000",
changeOrigin: true,
secure: true,
}
}
},
})