提交 64a8b213 编写于 作者: fxy060608's avatar fxy060608

feat(cli): easycom (uni_modules)

上级 cdbe8245
......@@ -8,7 +8,7 @@ const {
capitalize
} = require('./util')
const {
const {
getJson,
parseJson
} = require('./json')
......@@ -32,10 +32,10 @@ function getNVueMainEntry () {
}
return nvueMainEntry
}
function getPagesJson () {
return processPagesJson(getJson('pages.json', true))
}
function getPagesJson () {
return processPagesJson(getJson('pages.json', true))
}
function parsePagesJson (content, loader) {
return processPagesJson(parseJson(content, true), loader)
......@@ -359,11 +359,45 @@ function getAutoComponentsByDir (componentsPath, absolute = false) {
return components
}
function initAutoImportScanComponents () {
const componentsPath = path.resolve(process.env.UNI_INPUT_DIR, 'components')
const components = getAutoComponentsByDir(componentsPath)
function initAutoComponents () {
const allComponents = {}
const componentsDirs = [path.resolve(process.env.UNI_INPUT_DIR, 'components')]
global.uniModules.forEach(module => {
componentsDirs.push(path.resolve(process.env.UNI_INPUT_DIR, 'uni_modules', module, 'components'))
})
componentsDirs.forEach(componentsDir => {
const currentComponents = getAutoComponentsByDir(componentsDir, true)
Object.keys(currentComponents).forEach(name => {
(allComponents[name] || (allComponents[name] = [])).push(currentComponents[name])
})
})
const components = {}
const conflictFiles = []
Object.keys(allComponents).forEach(name => {
const files = allComponents[name]
components[name] = files[0]
if (files.length > 1) {
conflictFiles.push(files)
}
})
if (conflictFiles.length > 0) {
conflictFiles.forEach(files => {
let usedFile
console.warn('easycom组件冲突:[' + files.map((file, index) => {
file = path.relative(process.env.UNI_INPUT_DIR, file)
if (index === 0) {
usedFile = file
}
return file
}).join(',') + '],优先使用:' + usedFile)
console.log('\n')
})
}
return components
}
function initAutoImportScanComponents () {
const components = initAutoComponents()
if (process.env.UNI_PLATFORM === 'quickapp-native') {
if (!uniQuickAppAutoImportScanComponents) {
uniQuickAppAutoImportScanComponents = getAutoComponentsByDir(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册