mirror of
http://36.133.248.69:3088/admin/RentWeAppFront.git
synced 2026-03-11 03:12:26 +08:00
init
This commit is contained in:
58
node_modules/@dcloudio/uni-h5/lib/extends-component-loader/index.js
generated
vendored
Normal file
58
node_modules/@dcloudio/uni-h5/lib/extends-component-loader/index.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const glob = require('glob')
|
||||
const loaderUtils = require('loader-utils')
|
||||
|
||||
const isWin = /^win/.test(process.platform)
|
||||
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
|
||||
|
||||
module.exports = function loader(source) {
|
||||
const options = loaderUtils.getOptions(this)
|
||||
const baseDir = options['base']
|
||||
const platformDir = options['platform']
|
||||
const extendsDir = options['extends']
|
||||
|
||||
const components = []
|
||||
const extendsFiles = []
|
||||
// extends目录均导出
|
||||
glob.sync('**/index.vue', {
|
||||
cwd: extendsDir
|
||||
}).forEach(file => {
|
||||
extendsFiles.push(file)
|
||||
components.push(normalizePath(path.join(extendsDir, file)))
|
||||
})
|
||||
|
||||
//base目录中有,extends无的导出
|
||||
glob.sync('**/index.vue', {
|
||||
cwd: baseDir
|
||||
}).forEach(file => {
|
||||
if (!extendsFiles.includes(file)) {
|
||||
components.push(normalizePath(path.join(baseDir, file)))
|
||||
}
|
||||
})
|
||||
//platform目录中有,extends无的导出
|
||||
glob.sync('**/index.vue', {
|
||||
cwd: platformDir
|
||||
}).forEach(file => {
|
||||
if (!extendsFiles.includes(file)) {
|
||||
components.push(normalizePath(path.join(platformDir, file)))
|
||||
}
|
||||
})
|
||||
|
||||
const componentsCode = components.map(component => {
|
||||
return `require('${component}').default`
|
||||
}).join(',')
|
||||
return `
|
||||
import Vue from 'vue'
|
||||
import baseMixin from 'uni-mixins/base'
|
||||
import animation from 'uni-mixins/animation'
|
||||
[${componentsCode}].forEach(component=>{
|
||||
component.mixins = component.mixins ? [].concat(baseMixin, component.mixins) : [baseMixin]
|
||||
component.mixins.push(animation)
|
||||
component.name = 'VUni' + component.name
|
||||
component.isReserved = true
|
||||
Vue.component(component.name, component)
|
||||
})
|
||||
`
|
||||
}
|
||||
Reference in New Issue
Block a user