Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/talljack/unplugin-remove
Auto remove some unused code like console and debugger
https://github.com/talljack/unplugin-remove
build esbuild plugin remove rolldown rollup rspack unplugin vite webpack
Last synced: about 20 hours ago
JSON representation
Auto remove some unused code like console and debugger
- Host: GitHub
- URL: https://github.com/talljack/unplugin-remove
- Owner: Talljack
- License: mit
- Created: 2022-09-15T07:04:06.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-23T08:00:48.000Z (9 months ago)
- Last Synced: 2024-05-01T19:59:47.648Z (9 months ago)
- Topics: build, esbuild, plugin, remove, rolldown, rollup, rspack, unplugin, vite, webpack
- Language: TypeScript
- Homepage:
- Size: 513 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# unplugin-remove
Auto remove `console[log|warn|error|info|debug]` and `debugger` in **production** mode.
## Install
```bash
[npm|pnpm] i unplugin-remove -Dor
yarn add unplugin-remove -D
```## Demo
Example: [`playground/`](./playground/)
Vite
```ts
// vite.config.ts
import viteRemove from 'unplugin-remove/vite'export default defineConfig({
plugins: [
viteRemove({ /* options */ }),
],
})
```
Rollup
```ts
// rollup.config.js
import rollupRemove from 'unplugin-remove/rollup'export default {
plugins: [
rollupRemove({ /* options */ }),
],
}
```
Webpack
```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
process.env.MODE === 'production' ? require('unplugin-remove/webpack')({ /* options */ }) : null,
].filter(Boolean),
}
```
esbuild
```ts
// esbuild.config.js
import { build } from 'esbuild'
import esbuildRemove from 'unplugin-remove/esbuild'build({
plugins: [esbuildRemove()],
})
```
Rspack (
⚠️
experimental)```ts
// rspack.config.js
const RspackPlugin = require('unplugin-remove/rspack').defaultmodule.exports = {
plugins: [
new rspack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
RspackPlugin(),
],
}
```
Rolldown
(
⚠️
experimental)
```ts
// rolldown.config.js
import { defineConfig } from 'rolldown'
import Rolldown from 'unplugin-remove/rolldown'export default defineConfig({
plugins: [
process.env.MODE === 'production' ? Rolldown() : null,
],
})
```
## Configuration
The following shows the default values of the configuration
```ts
Remove({
// don't remove console.([log|warn|error|info|debug]) and debugger these module
external: [],// remove console type of these module
// enum: ['log', 'warn', 'error', 'info', 'debug']
consoleType: ['log'],// filters for transforming targets
include: [/\.[jt]sx?$/, /\.vue\??/],
exclude: [/node_modules/, /\.git/]
})
```## CHANGELOG
You can see [CHANGELOG](./CHANGELOG.md) here.
## License
MIT License © 2022-PRESENT [Talljack](https://github.com/talljack)