In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "vue how to get rid of all console.log output". In daily operation, I believe many people have doubts about how vue removes all console.log output. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "how vue removes all console.log output". Next, please follow the editor to study!
Vue package removes all console.log output installation plug-ins npm install babel-plugin-transform-remove-console-- save-dev add configuration
Install the babel-plugin-transform-remove-console development dependency, and then add nodes to the plugin of the project's babel.config.js. There will be no console warning in build.
The following configuration removes all console output statements from both the development environment and the production environment.
But the babel.config.js file is shared globally, and all console will be removed from both the development phase and the production phase. What should we do if we want to keep the console during the development phase?
As follows:
Code:
/ / the babel plug-in array const proPlugins = []; / / if the project is currently in production, use the plug-in if without console (process.env.NODE_ENV = 'production') {proPlugins.push (' transform-remove-console');} module.exports = {presets: ['@ vue/cli-plugin-babel/preset'], plugins: [. ProPlugins]} vue npm run build package to remove console and warning
You will certainly print some data in the local development environment, but if you upload it to the formal environment, you certainly can't have it any more, but you can't comment it out line by line. This is very troublesome, so vue actually has this configuration when configuring, but you need to modify it in the configuration file yourself, so it is convenient for your development 2 to achieve the level of laziness. Let's talk about this configuration.
Actually, just two lines of code will be fine.
Find here in the webpack.prod.conf.js under build to add
Drop_console: true,pure_funcs: ['console.log'] at this point, the study on "how vue removes all console.log output" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.