2017-04-19 1 views
0

React를 사용하여 웹 응용 프로그램을 작성하고 Webpack을 사용하여 빌드합니다. 하지만 프로덕션 빌드에서는 사람들이 UID와 같은 정보를 볼 수 없기 때문에 모든 콘솔 로그 문을 없애기를 원합니다. Webpack에서 모든 콘솔 로그를 자동으로 제거하도록 설정할 수 있습니까? 나는 p flag를 시도했지만 그렇게하지는 않았다.콘솔 로그를 제거하는 방법

+4

가능한 중복 : // stackoverflow.com/questions/41040266/remove-console-logs-with-webpack-uglify) –

답변

1

이 구성으로 UglifyJsPlugin를 사용해보십시오 :

new webpack.optimize.UglifyJsPlugin({ 
      compress: { 
       warnings: false, 
       screw_ie8: true, 
       conditionals: true, 
       unused: true, 
       comparisons: true, 
       sequences: true, 
       dead_code: true, 
       evaluate: true, 
       if_return: true, 
       join_vars: true, 
       drop_console: true, 
       drop_debugger: true, 
       global_defs: { 
        __REACT_HOT_LOADER__: undefined // eslint-disable-line no-undefined 
       } 
      }, 
      minimize: true, 
      debug: false, 
      sourceMap: true, 
      output: { 
       comments: false 
      }, 

     }), 

당신이있어 전체 설정 파일을 볼 수 https://github.com/jquintozamora/react-typescript-webpack2-cssModules-postCSS/blob/master/webpack/webpack.config.prod.js

(HTTP [웹팩 & 추하게와 console.logs 제거]의
관련 문제