diff --git a/packages/vue-cli-plugin-uni/index.js b/packages/vue-cli-plugin-uni/index.js index 2370cf980078afca6b57d85957b6a6d7e987d5be..d37006b25fd8862f174e61f5f7af12fb89256758 100644 --- a/packages/vue-cli-plugin-uni/index.js +++ b/packages/vue-cli-plugin-uni/index.js @@ -1,4 +1,3 @@ -const fs = require('fs') const path = require('path') const { @@ -82,27 +81,6 @@ module.exports = (api, options) => { return chainWebpack(webpackConfig, options) }) }) - - if ( - process.env.UNI_PLATFORM === 'h5' || - ( - process.env.UNI_PLATFORM === 'app-plus' && - process.env.UNI_USING_V3 - ) - ) { - const migrate = require('@dcloudio/uni-migration') - const wxcomponentDirs = [path.resolve(process.env.UNI_INPUT_DIR, 'wxcomponents')] - global.uniModules.forEach(module => { - wxcomponentDirs.push(path.resolve(process.env.UNI_INPUT_DIR, 'uni_modules', module, 'wxcomponents')) - }) - wxcomponentDirs.forEach(wxcomponentsDir => { - if (fs.existsSync(wxcomponentsDir)) { // 转换 mp-weixin 小程序组件 - migrate(wxcomponentsDir, false, { - silent: true // 不输出日志 - }) - } - }) - } } module.exports.defaultModes = { diff --git a/packages/vue-cli-plugin-uni/lib/env.js b/packages/vue-cli-plugin-uni/lib/env.js index ce1863fb3ce4beadbcba4dfbf5e513a7829df39f..3f3eb023f44086f9f69607058681850d626d624f 100644 --- a/packages/vue-cli-plugin-uni/lib/env.js +++ b/packages/vue-cli-plugin-uni/lib/env.js @@ -421,6 +421,27 @@ global.uniPlugin.configureEnv.forEach(configureEnv => { configureEnv() }) +if ( + process.env.UNI_PLATFORM === 'h5' || + ( + process.env.UNI_PLATFORM === 'app-plus' && + process.env.UNI_USING_V3 + ) +) { + const migrate = require('@dcloudio/uni-migration') + const wxcomponentDirs = [path.resolve(process.env.UNI_INPUT_DIR, 'wxcomponents')] + global.uniModules.forEach(module => { + wxcomponentDirs.push(path.resolve(process.env.UNI_INPUT_DIR, 'uni_modules', module, 'wxcomponents')) + }) + wxcomponentDirs.forEach(wxcomponentsDir => { + if (fs.existsSync(wxcomponentsDir)) { // 转换 mp-weixin 小程序组件 + migrate(wxcomponentsDir, false, { + silent: true // 不输出日志 + }) + } + }) +} + if (process.env.UNI_PLATFORM.startsWith('mp-')) { console.log('小程序各家浏览器内核及自定义组件实现机制存在差异,可能存在样式布局兼容问题,参考:https://uniapp.dcloud.io/matter?id=mp') } @@ -429,4 +450,4 @@ runByHBuilderX && console.log('正在编译中...') module.exports = { manifestPlatformOptions: platformOptions -} +}