https://github.com/pubdreamcc/babel-plugin-resolve-vconsole
A babel plugin to automatically remove the vconsole in the production environment
https://github.com/pubdreamcc/babel-plugin-resolve-vconsole
babel babel-plugin
Last synced: about 1 month ago
JSON representation
A babel plugin to automatically remove the vconsole in the production environment
- Host: GitHub
- URL: https://github.com/pubdreamcc/babel-plugin-resolve-vconsole
- Owner: pubdreamcc
- Created: 2020-12-08T02:54:37.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-12-24T03:50:30.000Z (over 5 years ago)
- Last Synced: 2025-01-07T19:38:24.611Z (over 1 year ago)
- Topics: babel, babel-plugin
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 公司移动端项目打包自动去除 vconsole 代码
## Usage
```npm
npm i babel-plugin-resolve-vconsole --save-dev (or yarn)
```
* in babel config file (eg .babelrc)
```js
{
plugins: ['remove-vconsole']
}
```
* webpack production config file
```js
{
test: /\.(js|jsx|mjs)$/,
include: paths.appSrc,
loader: require.resolve('babel-loader'),
options: {
customize: require.resolve(
'babel-preset-react-app/webpack-overrides'
),
plugins: ['remove-vconsole', ...],
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: true,
cacheCompression: true,
compact: true
}
}
```
打包之后,自动去除 Vconsole 的 引入
```js
import VConsole from 'vconsole';
new VConsole();
```