diff --git a/packages/webpack-uni-mp-loader/lib/plugin/generate-json.js b/packages/webpack-uni-mp-loader/lib/plugin/generate-json.js index 80655b696119f29dd645ca8bd064ac72f799911e..493b6f4779bbb4599eab92ab4d987747da09e78b 100644 --- a/packages/webpack-uni-mp-loader/lib/plugin/generate-json.js +++ b/packages/webpack-uni-mp-loader/lib/plugin/generate-json.js @@ -95,6 +95,8 @@ function analyzeUsingComponents () { // }, {}) } +const parseRequirePath = path => /^[A-z]/.test(path) ? `./${path}` : path + function normalizeUsingComponents (file, usingComponents) { const names = Object.keys(usingComponents) if (!names.length) { @@ -102,7 +104,7 @@ function normalizeUsingComponents (file, usingComponents) { } file = path.dirname('/' + file) names.forEach(name => { - usingComponents[name] = normalizePath(path.relative(file, usingComponents[name])) + usingComponents[name] = normalizePath(parseRequirePath(path.relative(file, usingComponents[name]))) }) return usingComponents }