-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathvite.config.ts
More file actions
95 lines (90 loc) · 2.87 KB
/
vite.config.ts
File metadata and controls
95 lines (90 loc) · 2.87 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
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
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import svgLoader from "vite-svg-loader"
import { VitePWA } from 'vite-plugin-pwa'
import { resolve } from 'path'
import zipPack from "vite-plugin-zip-pack" // make dist.zip file
import {dateFormatter} from "./src/utility";
import fs from 'fs'
const timeStringNow = dateFormatter(new Date(), 'yyyy-MM-dd-hh-mm-ss')
// Plugin to handle markdown files as raw text
const markdownPlugin = () => {
return {
name: 'markdown-loader',
transform(code: string, id: string) {
if (id.endsWith('.md')) {
return {
code: `export default ${JSON.stringify(code)}`,
map: null
}
}
}
}
}
// https://vitejs.dev/config/
export default defineConfig({
server: {
host: '0.0.0.0',// 自定义主机名
port: 1021,// 自定义端口
https: false,
proxy: {
'/dev': {
// target: 'http://localhost:3000',
target: 'http://kylebing.cn:3000',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/dev/, '/'),
},
}
},
base: './',
plugins: [
vue(),
svgLoader(),
markdownPlugin(),
VitePWA({
injectRegister: 'auto',
registerType: 'autoUpdate',
devOptions: {
// 开发模式不注入 dev-sw,避免对不存在的 dev-sw.js 注册失败(控制台 404)
enabled: false
},
// MANIFEST PWA https://vite-pwa-org.netlify.app/guide/pwa-minimal-requirements.html
includeAssets: ['logo.svg', 'apple-touch-icon.png', 'mask-icon.svg', 'favicon.png'],
manifest: {
name: '标题日记',
short_name: "日记",
theme_color: "#373737",
start_url: "./",
display: "standalone",
background_color: "#373737",
icons: [
{
src: "logo.svg",
sizes: "512x512",
type: "image/svg+xml",
purpose: "any",
},
{
src: "appicon-apple.png",
sizes: "512x512",
type: "image/png",
purpose: "any",
},
],
},
}),
zipPack({
inDir: 'dist',
outDir: 'archive',
outFileName: `diary-${timeStringNow}.zip`,
pathPrefix: ''
})
],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'@/view': resolve(__dirname, './src/view'),
'@/api': resolve(__dirname, './src/api'),
},
},
})