diff --git a/packages/vue-cli-plugin-uni/lib/env.js b/packages/vue-cli-plugin-uni/lib/env.js index 02c09c86d58303dcfe569e6741cfdf111ae33962..1780f406c25fdc9fbdfe070ff77bfe76b697080c 100644 --- a/packages/vue-cli-plugin-uni/lib/env.js +++ b/packages/vue-cli-plugin-uni/lib/env.js @@ -321,11 +321,17 @@ if ( require('@dcloudio/uni-cli-shared/lib/cache').restore() } } - -process.UNI_AUTO_COMPONENTS = [{ - pattern: new RegExp('uni-(.*)'), - replacement: '@/components/uni-$1/uni-$1.vue' -}] +// 组件自动导入配置 +process.UNI_AUTO_COMPONENTS = [] +const usingAutoImportComponents = pagesJsonObj.usingAutoImportComponents +if (usingAutoImportComponents) { + Object.keys(usingAutoImportComponents).forEach(pattern => { + process.UNI_AUTO_COMPONENTS.push({ + pattern: new RegExp(pattern), + replacement: usingAutoImportComponents[pattern] + }) + }) +} runByHBuilderX && console.log(`正在编译中...`)