From 189d20aa298db73313afd2484867107b687cb06b Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Mon, 28 Oct 2019 18:52:16 +0800 Subject: [PATCH] chore(cli): add perf msg --- packages/vue-cli-plugin-uni/lib/env.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/vue-cli-plugin-uni/lib/env.js b/packages/vue-cli-plugin-uni/lib/env.js index d8f523fd80..12f0077c2c 100644 --- a/packages/vue-cli-plugin-uni/lib/env.js +++ b/packages/vue-cli-plugin-uni/lib/env.js @@ -178,6 +178,7 @@ const warningMsg = : `uni-app将于2019年11月1日起停止支持非自定义组件模式 [详情](https://ask.dcloud.net.cn/article/36385)` const needWarning = !platformOptions.usingComponents || usingComponentsAbsent +let hasNVue = false // 输出编译器版本等信息 if (process.env.UNI_USING_NATIVE) { console.log('当前nvue编译模式:' + (isNVueCompiler ? 'uni-app' : 'weex') + @@ -195,9 +196,10 @@ if (process.env.UNI_USING_NATIVE) { info = '编译器版本:' + pagesPkg['uni-app']['compilerVersion'] } const glob = require('glob') - if (glob.sync('pages/**/*.nvue', { + hasNVue = !!glob.sync('pages/**/*.nvue', { cwd: process.env.UNI_INPUT_DIR - }).length) { + }).length + if (hasNVue) { console.log(info) console.log(modeText) if (needWarning) { @@ -219,6 +221,15 @@ if (process.env.UNI_USING_NATIVE) { } } catch (e) {} } +if (process.env.NODE_ENV !== 'production') { // 运行模式性能提示 + let perfMsg = `请注意运行时,因日志输出、sourcemap以及未压缩源码等原因,性能不如发行模式。` + if (hasNVue) { // app-nvue + perfMsg = perfMsg + `尤其是app-nvue的sourcemap影响较大` + } else if (process.env.UNI_PLATFORM.indexOf('mp-') === 0) { // 小程序 + perfMsg = perfMsg + `请勿直接发布运行模式的代码` + } + console.log(perfMsg) +} const moduleAlias = require('module-alias') -- GitLab