-
vite 빌드 시 콘솔 로그 제거하기Developer 2024. 2. 16. 16:00728x90
개발하면서 디버깅을 하기 위해 console.log를 많이들 찍어보실 거예요.
저도 참 많이 찍는답니다.. 😂
파일 대비 145%... 전 회사에서는 스니펫을 활용하여 특정 문자도 콘솔 로그에 찍히게 하여 제가 작성한 콘솔로그는 특정 문자로 검색하여 지우곤 했었는데요..
혼자 프로젝트를 하다 보니 그냥 콘솔 로그를 막 찍게 되더군요..
그냥 검색해서 다 지워버려도 되긴 하지만, 운영에서만 콘솔 로그가 찍히지 않으면 되잖아요 ?! 🤣
그래서 찾아보았습니다!!!
바로바로
.
.
.
vite-plugin-remove-console
A vite plugin that remove the types of console in the production environment. Latest version: 2.2.0, last published: 2 months ago. Start using vite-plugin-remove-console in your project by running `npm i vite-plugin-remove-console`. There are 2 other proje
www.npmjs.com
사용법은 아주 간단합니다.
🌟 vite-plugin-remove-console 설치
# npm npm install vite-plugin-remove-console -D # or yarn yarn add vite-plugin-remove-console -D # or pnpm pnpm add vite-plugin-remove-console -D
⚡️ vite.config.js 설정
import { fileURLToPath, URL } from 'node:url'; import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import removeConsole from 'vite-plugin-remove-console'; // 추가 export default defineConfig({ plugins: [ vue(), removeConsole(), // 추가 ], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, });
이제 npm run build 해보면 빌드된 프로젝트에는 콘솔로그가 전부 사라지게 됩니다!
728x90'Developer' 카테고리의 다른 글
MAC 로컬 개발 환경 셋팅 - SSL 인증된 https 도메인 적용하기 (0) 2024.02.23 postMessage를 활용한 iframe 통신하기 (0) 2024.02.23 Push 정책 설정하기 (0) 2024.02.07 다수의 프로젝트 병렬로 빌드&배포하기 (0) 2024.02.06 팀즈 WebHook으로 에러 알림받기 (0) 2024.02.02