diff --git a/packages/webpack-uni-mp-loader/lib/script-new.js b/packages/webpack-uni-mp-loader/lib/script-new.js index 73cd147d0dab970d16608e5c5005bb9295d8052d..6f3eadf4a3862c348f72f8f9df1315e70f3d146f 100644 --- a/packages/webpack-uni-mp-loader/lib/script-new.js +++ b/packages/webpack-uni-mp-loader/lib/script-new.js @@ -59,6 +59,17 @@ module.exports = function (content, map) { } } + if ( // windows 上 page-meta, navigation-bar 可能在不同盘上 + /^win/.test(process.platform) && + path.isAbsolute(resourcePath) && + ( + resourcePath.indexOf('page-meta') !== -1 || + resourcePath.indexOf('navigation-bar') !== -1 + ) + ) { + resourcePath = normalizePath(path.relative(process.env.UNI_CLI_CONTEXT, resourcePath)) + } + if (!type) { type = 'Component' } diff --git a/packages/webpack-uni-mp-loader/lib/template.js b/packages/webpack-uni-mp-loader/lib/template.js index 93ab3a9e97a9ca33282378d0f8a3a9eadc485403..36dbff25457c5c8577f1cba0fe7588a7210a4503 100644 --- a/packages/webpack-uni-mp-loader/lib/template.js +++ b/packages/webpack-uni-mp-loader/lib/template.js @@ -4,6 +4,7 @@ const loaderUtils = require('loader-utils') const { removeExt, + normalizePath, getPlatformExts, getShadowTemplate } = require('@dcloudio/uni-cli-shared') @@ -43,7 +44,19 @@ module.exports = function (content, map) { if (vueLoaderOptions) { const globalUsingComponents = getGlobalUsingComponents() const realResourcePath = path.relative(process.env.UNI_INPUT_DIR, this.resourcePath) - const resourcePath = normalizeNodeModules(removeExt(realResourcePath) + templateExt) + let resourcePath = normalizeNodeModules(removeExt(realResourcePath) + templateExt) + + if ( // windows 上 page-meta, navigation-bar 可能在不同盘上 + /^win/.test(process.platform) && + path.isAbsolute(resourcePath) && + ( + resourcePath.indexOf('page-meta') !== -1 || + resourcePath.indexOf('navigation-bar') !== -1 + ) + ) { + resourcePath = normalizePath(path.relative(process.env.UNI_CLI_CONTEXT, resourcePath)) + } + const wxComponents = getWXComponents(resourcePath.replace(path.extname(resourcePath), '')) const params = loaderUtils.parseQuery(this.resourceQuery)