🔧工具(deps): add deps: vite-plugin-html

This commit is contained in:
2024-03-21 14:01:53 +08:00
parent c0ea4c40b0
commit 2b1c06608b
7 changed files with 298 additions and 116 deletions

View File

@@ -18,6 +18,9 @@ import autoprefixer from 'autoprefixer'
import viteCompression from 'vite-plugin-compression'
import imagemin from 'unplugin-imagemin/vite'
import { createHtmlPlugin } from 'vite-plugin-html'
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd())
return {
@@ -45,6 +48,28 @@ export default defineConfig(({ mode, command }) => {
},
plugins: [
vue(),
createHtmlPlugin({
minify: true,
/**
* 在这里写entry后你将不需要在`index.html`内添加 script 标签,原有标签需要删除
* @default src/main.ts
*/
entry: 'src/main.ts',
filename: 'index.html',
/**
* 如果你想将 `index.html`存放在指定文件夹,可以修改它,否则不需要配置
* @default index.html
*/
template: 'index.html',
/**
* 需要注入 index.html ejs 模版的数据
*/
inject: {
data: {
title: env.VITE_TITLE_NAME
}
}
}),
imagemin({
// Default mode sharp. support squoosh and sharp
mode: 'sharp',