🔧工具(deps): add deps: vite-plugin-html
This commit is contained in:
@@ -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',
|
||||
|
Reference in New Issue
Block a user