Tencent/kbone

小程序自定义组件无法正确编译

AymaxLi opened this issue · 1 comments

背景

按照文档中 demo10 的示例写了小程序自定义组件,并配置了 generate.wxCustomComponent

  generate: {
    app: 'default',
    autoBuildNpm: 'npm',
    wxCustomComponent: {
      root: '../src/pages/thbi/components/T4',
      usingComponents: {
        T4Provider: 'T4Provider/index.js',
      },
    },
  },

组件代码
image

kbone 编译期间,emitting MpPlugin 阶段提示 path not exists: "../src/pages/thbi/components/T4"
问题应该是出在这里,但是这个相对路径是正确的

> vue-kbone@0.0.1 dev
> npm run mp


> vue-kbone@0.0.1 mp
> cross-env NODE_ENV=development webpack --config build/webpack.mp.config.js --progress --hide-modules

10% building 0/0 modules 0 active
webpack is watching the files…

95% emitting MpPluginpath not exists: "../src/pages/thbi/components/T4"
98% after emitting SizeLimitsPlugin
start building dependencies...


built dependencies successfully

Hash: a68b31f5a86d624822b8
Version: webpack 4.46.0
Time: 680ms
Built at: 2022/09/20 14:35:43
                            Asset       Size  Chunks             Chunk Names
                        ../app.js   2.15 KiB          [emitted]
                      ../app.json  312 bytes          [emitted]
                      ../app.wxss   7.74 KiB          [emitted]
                     ../config.js  894 bytes          [emitted]
     ../custom-component/index.js    6.2 KiB          [emitted]
   ../custom-component/index.json  166 bytes          [emitted]
   ../custom-component/index.wxml  440 bytes          [emitted]
   ../custom-component/index.wxss    0 bytes          [emitted]
     ../node_modules/.miniprogram    0 bytes          [emitted]
                  ../package.json  185 bytes          [emitted]
                 ../pages/base.js   13.4 KiB          [emitted]
     ../pages/thbi-index/index.js  693 bytes          [emitted]
   ../pages/thbi-index/index.json  150 bytes          [emitted]
   ../pages/thbi-index/index.wxml  190 bytes          [emitted]
   ../pages/thbi-index/index.wxss  102 bytes          [emitted]
  ../pages/thbi-row-data/index.js  696 bytes          [emitted]
../pages/thbi-row-data/index.json  150 bytes          [emitted]
../pages/thbi-row-data/index.wxml  190 bytes          [emitted]
../pages/thbi-row-data/index.wxss  105 bytes          [emitted]
           ../project.config.json     15 KiB          [emitted]
                             1.js    612 KiB       1  [emitted]
                             2.js    233 KiB       2  [emitted]
                           2.wxss   5.22 KiB       2  [emitted]
            commonDependencies.js   6.84 KiB       0  [emitted]  commonDependencies
                    thbi-index.js   23.1 KiB       3  [emitted]  thbi-index
                  thbi-index.wxss   4.54 KiB       3  [emitted]  thbi-index
                 thbi-row-data.js   18.4 KiB       4  [emitted]  thbi-row-data
               thbi-row-data.wxss   1.18 KiB       4  [emitted]  thbi-row-data
Entrypoint thbi-index = commonDependencies.js 1.js 2.wxss 2.js thbi-index.wxss thbi-index.js
Entrypoint thbi-row-data = commonDependencies.js 1.js 2.wxss 2.js thbi-row-data.wxss thbi-row-data.js

小程序编译报错,自定义组件没有被成功编译
image

已确定原因:CleanWebpackPlugin 插件影响导致自定义组件生成目录被删除