vite面试题提交

This commit is contained in:
2026-06-26 17:56:46 +08:00
parent 40a1a2248b
commit 82c0f31cae
7 changed files with 1176 additions and 19 deletions

View File

@@ -1,30 +1,16 @@
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import noConsole from './plugins/plugin-noconsole'
function helloPlugin() {
console.log("hello Plugin")
return {
name: 'helloPlugin',
transform(src, id) {
// 只处理 src 目录下的文件,跳过 node_modules
if (!id.includes('/src/')) return null
// 生产环境:自动移除 console.log
if (process.env.NODE_ENV === 'production') {
const result = src.replace(/console\.log\([^)]*\);?/g, '')
return {code: result, map: null}
}
return null
}
}
}
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
helloPlugin()
// noConsole()
],
clear:true
})