3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

viteでbuild時にconsole.logを削除する

Last updated at Posted at 2022-09-09

build時に自動的にconsole.logを削除してほしい

そもそもeslintでconsole.logはwarnにしているわけですが、手っ取り早くlogを取りたいときもあってたまにconsole.logを使ってしまいます。

そんなときはこれ!

vite-plugin-remove-console

npm install vite-plugin-remove-console -D

configはこうだ

vite.config.ts
import { defineConfig } from 'vite';
import removeConsole from 'vite-plugin-remove-console';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    removeConsole()
  ]
});

これでデバッグ用のconsole.logを削除できます。まあdebugとか使ったほうが良いよなぁ、と思いつつもついついconsole.logを使ってしまう。やめたほうが良いな。やめよう。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?