diff --git a/packages/vue-cli-plugin-uni/index.js b/packages/vue-cli-plugin-uni/index.js index d64d1f1160005a5c3fc1dda3ba2924f8356c8515..4d62acda9913b7049c5a7d752098f72d125b0321 100644 --- a/packages/vue-cli-plugin-uni/index.js +++ b/packages/vue-cli-plugin-uni/index.js @@ -53,6 +53,10 @@ module.exports = (api, options) => { vueConfig = vueConfig(options, api) } + if (options.pages) { // 允许 vue.config.js pages 覆盖 + delete vueConfig.pages + } + Object.assign(options, { // TODO 考虑非 HBuilderX 运行时,可以支持自定义输出目录 outputDir: process.env.UNI_OUTPUT_TMP_DIR || process.env.UNI_OUTPUT_DIR, assetsDir diff --git a/packages/webpack-uni-pages-loader/lib/platforms/h5.js b/packages/webpack-uni-pages-loader/lib/platforms/h5.js index b42548ae7c65eec0fdca416661514274da981893..a6b1bfc1bb7dc3105aa513c928cd545f101d36c2 100644 --- a/packages/webpack-uni-pages-loader/lib/platforms/h5.js +++ b/packages/webpack-uni-pages-loader/lib/platforms/h5.js @@ -362,15 +362,17 @@ module.exports = function (pagesJson, manifestJson, loader) { configurePages(pagesJson, manifestJson, loader) }) - const loaderUtils = require('loader-utils') - const params = loaderUtils.parseQuery(loader.resourceQuery) - if (params.pages) { - try { - const pages = JSON.parse(params.pages) - if (Array.isArray(pages)) { - filterPages(pagesJson, pages) - } - } catch (e) {} + if (loader.resourceQuery) { + const loaderUtils = require('loader-utils') + const params = loaderUtils.parseQuery(loader.resourceQuery) + if (params.pages) { + try { + const pages = JSON.parse(params.pages) + if (Array.isArray(pages)) { + filterPages(pagesJson, pages) + } + } catch (e) {} + } } const pageComponents = getPageComponents(inputDir, pagesJson)