1.0.6 • Published 4 months ago
console-hide v1.0.6
hide-console-output
一个用于移除代码中 console 输出的 Vite 插件。
安装
npm install hide-console-output
使用
在 vite.config.ts 中添加插件:
import removeConsolePlugin from "hide-console-output";
export default defineConfig({
plugins: [
removeConsolePlugin({
include: /\.(js|ts|jsx|tsx)$/, // 默认匹配的文件类型
exclude: /node_modules/, // 默认排除的文件
methods: ["log", "warn", "error", "info", "debug"], // 默认移除的 console 方法
environments: ["production", "prod", "pro"], // 默认在生产环境生效
}),
],
});
选项
选项 | 类型 | 默认值 | 描述 |
---|---|---|---|
include | string | /\.(js | ts | jsx | tsx)$/ | 匹配的文件类型 |
exclude | string | node_modules | 排除的文件 |
methods | string[] | ["log", "warn", "error", "info", "debug"] | 移除的 console 方法 |
environments | string[] | ["production", "prod", "pro"] | 生效的环境 |