插件生命周期钩子文档
手写插件
导入 和 引入
import MyVitePlugin from "./plugins/vite-aliases.ts";
plugins: [
MyVitePlugin()
],
vite-aliases.ts 文件
export default (): any => {
return {
/**
*
* @param config vite.config.ts 中写的配置会原封不动的返回
* @param env { mode: 'development', command: 'serve',isSsrBuild: false, isPreview: false }
* @returns Object
*/
config(config: any, env: any) {
// console.log('😁😁😁config, env ===>', config, env);
console.log('😁😁😁1111111111111');
return {}
},
transformIndexHtml(html: any) {
return html.replace(
/<title>(.*?)<\/title>/,
`<title>网站标题!</title>`
)
}
}
}