简体   繁体   English

如何在使用“create-react-app”创建的 reactjs 的生产过程中删除 console.log

[英]how to remove console.log during production in reactjs created with `create-react-app`

i have create app using npx create-react-app i want to remove console.log() during production but i googled i found this babel-plugin-transform-remove-console plugin configured using this link https://babeljs.io/docs/en/babel-plugin-transform-remove-console/#via-babelrc-recommended unfortunatly it does't seem workout for me.我已经使用 npx create-react-app我想在生产过程中删除console.log()但我用谷歌搜索我发现这个babel-plugin-transform-remove-console插件是使用这个链接配置的https://babeljs.io/ docs/en/babel-plugin-transform-remove-console/#via-babelrc-recommended不幸的是,它对我来说似乎没有锻炼。 Note i create.babelrc file manually in my root dir.注意我在我的根目录中手动创建 .babelrc 文件。

  • step 1: npm install babel-plugin-transform-remove-console --save-dev第 1 步: npm 安装 babel-plugin-transform-remove-console --save-dev
  • step 2: npm run eject第 2 步: npm run eject
  • step 3: Edit package.json file第 3 步:编辑 package.json 文件
    "babel": { "presets": [ "react-app" ], "env": { "production": { "plugins": [ "transform-remove-console" ] } } }
  • step 4: npm run build第 4 步: npm run build

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在使用 create-react-app 创建的 React 应用程序的生产版本中删除 console.log? - How can remove console.log in the production build of a React application created using create-react-app? 为什么我的 create-react-app console.log 两次? - Why does my create-react-app console.log twice? ReactJS 应用程序在 Edge 104 上使用 create-react-app 创建 - ReactJS App Created with create-react-app on Edge 104 Console.log在Reactjs应用程序上不起作用 - Console.log not working on Reactjs app 如何删除 React App 符号和名称或“使用 create-react-app 创建的网站”? - How can I remove the React App symbol and name or the “Website created using create-react-app”? 反应不是我创建的奇怪的console.log - React weird console.log not created by me 在ReactJs生产模式下停用Console.log和Logger或Redux存储 - Deactivate Console.log and Logger or the Redux store in ReactJs production Mode 如何在 Create React App 中使用 Enzyme 和 Jest 从挂载的组件中读取 console.log - How to read console.log from a mounted component with Enzyme and Jest in Create React App 如何运行Salesforce中create-react-app创建的React App - How to run React App created by create-react-app in Salesforce 如何在reactjs中以模态打开console.log - HOW TO OPEN console.log in modal in reactjs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM