Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhubbardsf/vite-plugin-svelte-console-remover
Vite Svelte plugin to remove console logs in prod.
https://github.com/jhubbardsf/vite-plugin-svelte-console-remover
console plugin svelte vite
Last synced: 4 days ago
JSON representation
Vite Svelte plugin to remove console logs in prod.
- Host: GitHub
- URL: https://github.com/jhubbardsf/vite-plugin-svelte-console-remover
- Owner: jhubbardsf
- License: mit
- Created: 2022-05-16T00:15:15.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-05-25T13:07:13.000Z (over 2 years ago)
- Last Synced: 2024-05-01T13:06:41.193Z (6 months ago)
- Topics: console, plugin, svelte, vite
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/vite-plugin-svelte-console-remover
- Size: 52.7 KB
- Stars: 35
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vite-plugin-svelte-console-remover
[![npm](https://img.shields.io/npm/v/vite-plugin-svelte-console-remover?style=flat-square)](https://www.npmjs.com/package/vite-plugin-svelte-console-remover)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/vite-plugin-svelte-console-remover?style=flat-square)](https://www.npmjs.com/package/vite-plugin-svelte-console-remover)
[![npm](https://img.shields.io/npm/dt/vite-plugin-svelte-console-remover?style=flat-square)](https://www.npmjs.com/package/vite-plugin-svelte-console-remover)
[![GitHub last commit](https://img.shields.io/github/last-commit/jhubbardsf/vite-plugin-svelte-console-remover?style=flat-square)](https://github.com/jhubbardsf/vite-plugin-svelte-console-remover)A Vite plugin that removes all console statements (log, group, dir, error, etc) from Svelte, JS, and TS files during build so they don't leak into production.
---
**What this doesn't do**: This does not remove **anything** from your codebase. Your console.logs will still be there. You'll still see them in development and any other non-production environment.
**What this does**: Removes all console statements from appearing on your production domain. They're removed during the build/tranform step, so they're stripped out of your production code.
## Example Use
```js
import adapter from '@sveltejs/adapter-auto';
import preprocess from 'svelte-preprocess';
import removeConsole from 'vite-plugin-svelte-console-remover';/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: preprocess(),
kit: {
adapter: adapter(),
vite: {
plugins: [removeConsole()],
}
}
}export default config;
```---
Note: You can accomplish something similar using esbuilds [drop](https://esbuild.github.io/api/#drop).