diff --git a/packages/vue-cli-plugin-uni/lib/cache-loader.js b/packages/vue-cli-plugin-uni/lib/cache-loader.js index 0b659b2aeccebe54f4a626f3c71295bae4c03d6e..af1941c8bb3aedd2760fdcf64cc0cf83b2cb642b 100644 --- a/packages/vue-cli-plugin-uni/lib/cache-loader.js +++ b/packages/vue-cli-plugin-uni/lib/cache-loader.js @@ -62,14 +62,14 @@ function read (key, callback) { } module.exports = { - createTemplateCacheLoader: function (api) { + createTemplateCacheLoader: function (api, id = 'uni-template-compiler') { return { resourceQuery: /type=uni-cache-loader-template/, use: [{ loader: 'cache-loader', ident: 'uni-cache-loader-template-options', options: Object.assign(api.genCacheConfig( - 'uni-template-compiler/' + process.env.UNI_PLATFORM, + id + '/' + process.env.UNI_PLATFORM, getPartialIdentifier() ), { read, diff --git a/packages/vue-cli-plugin-uni/lib/util.js b/packages/vue-cli-plugin-uni/lib/util.js index b0112047379ac3a77c985830752cc69909616fc3..fd85fa57024c5892c14dd1b42f9515635e1023c1 100644 --- a/packages/vue-cli-plugin-uni/lib/util.js +++ b/packages/vue-cli-plugin-uni/lib/util.js @@ -16,17 +16,16 @@ module.exports = { 'link,meta,param,source,track,wbr' ), getPartialIdentifier () { - if (partialIdentifier) { - return partialIdentifier - } - partialIdentifier = { - 'UNI_COMPILER_VERSION': require('../package.json').version - } - Object.keys(process.env).forEach(name => { - if (name.indexOf('UNI_') === 0) { - partialIdentifier[name] = process.env[name] + if (!partialIdentifier) { + partialIdentifier = { + 'UNI_COMPILER_VERSION': require('../package.json').version } - }) + Object.keys(process.env).forEach(name => { + if (name.indexOf('UNI_') === 0) { + partialIdentifier[name] = process.env[name] + } + }) + } return partialIdentifier } }