Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
stdj_h5
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2025-11-04 14:39:04 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
76014145a5184a06e4bb8cfde75b9869740ef829
76014145
1 parent
ed468661
feat: 添加vite-plugin-html插件并配置HTML压缩选项
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
package.json
pnpm-lock.yaml
vite.config.js
package.json
View file @
7601414
...
...
@@ -42,6 +42,7 @@
"tailwindcss"
:
"^3.4.1"
,
"unplugin-auto-import"
:
"^0.17.5"
,
"unplugin-vue-components"
:
"^0.26.0"
,
"vite"
:
"^5.1.0"
"vite"
:
"^5.1.0"
,
"vite-plugin-html"
:
"^3.2.2"
}
}
...
...
pnpm-lock.yaml
View file @
7601414
This diff is collapsed. Click to expand it.
vite.config.js
View file @
7601414
/*
* @Date: 2025-10-30 10:27:43
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-11-0
3 09:48:52
* @LastEditTime: 2025-11-0
4 14:37:28
* @FilePath: /stdj_h5/vite.config.js
* @Description: 文件描述
*/
...
...
@@ -15,6 +15,7 @@ import tailwindcss from 'tailwindcss'
import
autoprefixer
from
'autoprefixer'
import
postcsspxtoviewport
from
'postcss-px-to-viewport'
import
{
createProxy
}
from
'./build/proxy'
import
{
createHtmlPlugin
}
from
'vite-plugin-html'
;
export
default
({
command
,
mode
})
=>
{
const
root
=
process
.
cwd
();
...
...
@@ -36,7 +37,21 @@ export default ({ command, mode }) => {
Components
({
resolvers
:
[
VantResolver
()],
dts
:
'src/components.d.ts'
})
}),
createHtmlPlugin
({
// 生产环境下的HTML压缩配置
minify
:
{
// 核心:删除HTML中的注释
removeComments
:
true
,
// 可选:其他压缩选项(按需开启)
collapseWhitespace
:
true
,
// 折叠空白字符
removeRedundantAttributes
:
true
,
// 移除冗余属性(如input的type="text")
removeScriptTypeAttributes
:
true
,
// 移除script标签的type="text/javascript"
removeStyleLinkTypeAttributes
:
true
,
// 移除style/link标签的type="text/css"
minifyCSS
:
true
,
// 压缩内嵌CSS
minifyJS
:
true
,
// 压缩内嵌JS
},
}),
],
resolve
:
{
alias
:
{
...
...
Please
register
or
login
to post a comment