From abdf9849e821492cba68794c5e37a83a839983a9 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Thu, 23 Dec 2021 20:26:27 +0800 Subject: [PATCH] chore(h5): optimization.moduleIds = 'hashed' # Conflicts: # packages/uni-cli-shared/lib/cache.js --- packages/uni-cli-shared/lib/cache.js | 9 ++++++--- packages/vue-cli-plugin-uni/lib/h5/index.js | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/uni-cli-shared/lib/cache.js b/packages/uni-cli-shared/lib/cache.js index ef8e296946..e2f27650e6 100644 --- a/packages/uni-cli-shared/lib/cache.js +++ b/packages/uni-cli-shared/lib/cache.js @@ -82,11 +82,14 @@ function updateComponentJson (name, jsonObj, usingComponents = true, type = 'Com const oldJsonStr = getJsonFile(name) if (oldJsonStr) { // update - if (usingComponents) { // merge usingComponents + if (usingComponents) { // merge usingComponents // 其实直接拿新的 merge 到旧的应该就行 const oldJsonObj = JSON.parse(oldJsonStr) - jsonObj.usingComponents = oldJsonObj.usingComponents || {} + jsonObj.usingComponents = oldJsonObj.usingComponents || {} jsonObj.usingAutoImportComponents = oldJsonObj.usingAutoImportComponents || {} + if (oldJsonObj.genericComponents) { + jsonObj.genericComponents = oldJsonObj.genericComponents + } if (oldJsonObj.usingGlobalComponents) { // 复制 global components(针对不支持全局 usingComponents 的平台) jsonObj.usingGlobalComponents = oldJsonObj.usingGlobalComponents } @@ -351,4 +354,4 @@ module.exports = { updateGenericComponents, getChangedJsonFileMap, getSpecialMethods -} +} diff --git a/packages/vue-cli-plugin-uni/lib/h5/index.js b/packages/vue-cli-plugin-uni/lib/h5/index.js index 2072a04d4f..82a26ba4f5 100644 --- a/packages/vue-cli-plugin-uni/lib/h5/index.js +++ b/packages/vue-cli-plugin-uni/lib/h5/index.js @@ -155,6 +155,9 @@ module.exports = { } }, plugins, + optimization: { + moduleIds: 'hashed' + }, devServer: { watchOptions: require('../util').getWatchOptions() } -- GitLab