vue : 自定义脚手架提示

时间:2023-03-09 16:37:59
vue : 自定义脚手架提示

做项目做烦了就想找点乐子。

比如,我们可以自定义脚手架提示。

 webpack.dev.conf.js 

54-78 行

module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port // Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`万物皆虚,万事皆允。 \nYour application is running here: http://${config.dev.host}:${port}`],
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
})) resolve(devWebpackConfig)
}
})
})

最后效果是这样的:

vue : 自定义脚手架提示