vite面试题提交
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user