方式一:stats对象
方式二:friendly-errors-webpack-plugin插件
npm i --save-D friendly-errors-webpack-plugin
webpack.config.js
plugins: [ new FriendlyErrorsWebpackPlugin({ compilationSuccessInfo: { messages: ['You application is running here http://localhost:3000'], notes: ['Some additionnal notes to be displayed unpon successful compilation'] }, onErrors: function (severity, errors) { // You can listen to errors transformed and prioritized by the plugin // severity can be 'error' or 'warning' }, }) ]