-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
95 lines (91 loc) · 3.29 KB
/
vite.config.js
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 path from 'path';
import process from 'process';
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue';
import Inspect from 'vite-plugin-inspect';
import { visualizer } from "rollup-plugin-visualizer";
import sitemapPlugin from 'vite-plugin-sitemap';
import ViteCustom404PagePlugin from './plugins/ViteCustom404PagePlugin';
import { dfsSearch } from "./assist/findFiles"
/** @type {import('vite').UserConfig} */
export default defineConfig({
resolve:{
alias:{
"particles.js":"modifiedPackage/particles.js/particles.js",
"process":"modifiedPackage/node-process/browser.js",
}
},
server: {
port: 81,
host: "0.0.0.0"
},base:"/",
appType:"mpa",
plugins: [vue(), Inspect(), visualizer({
gzipSize: true,
brotliSize: true,
emitFile: false,
filename: "./temp/test.html", //分析图生成的文件名
open: true //如果存在本地服务端口,将在打包后自动展示
}), sitemapPlugin(
{
hostname: 'http://www.kuankuan.site/',
changefreq: 'weekly',
outDir:"builded/dist"
}
), ViteCustom404PagePlugin()],
build: {
outDir:"builded/dist",
rollupOptions: {
input: dfsSearch(path.resolve("./"), str => str.endsWith(".html") || str.endsWith(".htm")),
output: {
manualChunks: {
markdown: ["showdown", "showdown-katex", "xss", "katex", "highlight.js"],
connections: [path.resolve(__dirname, "./src/common/script/connection.js")],
normal: [path.resolve(__dirname,"./src/common/script/normal.js")],
infomations : [path.resolve(__dirname,"./src/common/script/infomations.js")],
initEnv:[
path.resolve(__dirname, "./src/common/script/all.js"),
path.resolve(__dirname, "./src/common/script/arraySort.js"),
path.resolve(__dirname, "./src/common/script/arrayBufferJsonSport.js"),
path.resolve(__dirname, "./src/common/script/storageEvent.js"),
path.resolve(__dirname, "./src/common/script/stringPoint.js"),
path.resolve(__dirname, "./src/common/script/browerInfo.js"),
path.resolve(__dirname, "./src/common/script/copy.js"),
"buffer","process"
]
}, entryFileNames: function (chunkInfo) {
let pathName = (path.dirname(chunkInfo.facadeModuleId).slice((__dirname.replace(/\\/g, "/")).length) + "/script/[name]-[hash].js").slice(1);
return pathName
},
chunkFileNames: function (chunkInfo) {
return "script/[name]-[hash].js"
},
assetFileNames: function (chunkInfo) {
if (chunkInfo.source === '/* vite internal call, ignore */'){
return chunkInfo.name
}
const extToDir={
'script':['.js'],
'style':['.css'],
'font':['.ttf','.woff','.woff2','.eot','.otf'],
'image':['.png','.jpg','.svg','.gif'],
}
for (const i in extToDir){
if (extToDir[i].some(ext=>chunkInfo.name.endsWith(ext))){
return `${i}/[name]-[hash].[ext]`
}
}
return "assets/[name]-[hash].[ext]"
}
}
},
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
minify: "terser",
target: "es2015"
}
})