cnf
2025-05-10 386fa0eca75ddc88165f9b73038f2a2239e1072e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const path = require('path')
 
const {
  removeExt,
  normalizePath
} = require('@dcloudio/uni-cli-shared')
const {
  getUsingComponentsCode
} = require('@dcloudio/uni-cli-shared/lib/pages')
 
module.exports = function (content, map) {
  this.cacheable && this.cacheable()
  const resourcePath = removeExt(
    normalizePath(path.relative(process.env.UNI_INPUT_DIR, this.resourcePath))
  )
  content = content + getUsingComponentsCode(resourcePath)
  // TODO 自动导入 vue 组件(h5,小程序,app[vue,nvue])
  // 1. 需要 template-loader 解析出所有自定义组件()
  // 2. 根据自定义组件信息生成引用代码
  // 3. node-modules中的组件不提供自动导入
  this.callback(null, content, map)
}