vconsole-webpack-plugin2
webpack plugin for vConsole
帮助开发者在移动端进行调试,本插件是在 vConsole 的基础上封装的 webpack
插件,通过 webpack
配置即可自动添加 vConsole
调试功能,方便实用。
安装
npm install vconsole-webpack-plugin2 --save-dev
使用
webpack.conf.js
文件配置里增加以下插件配置即可
// 引入插件var vConsolePlugin = ; moduleexports = ... plugins: filter: // 需要过滤的入口文件 enable: true // 发布代码前记得改回 false ... ...
vConsole
作为一个调试模块,注定了需要在发布前把它去掉,为了避免人为操作失误而影响线上功能,这里建议配置如下:
package.json
文件配置:
scripts:
webpack.conf.js
配置:
// 引入插件var vConsolePlugin = ; // 接收运行参数const argv = // use 'webpack --debug' argv; moduleexports = ... plugins: enable: !!argvdebug ... ...
这样,在开发的时候运行 npm run dev
,发布的时候运行 npm run prod
即可。