diff --git a/packages/uni-cli-shared/lib/preprocess.js b/packages/uni-cli-shared/lib/preprocess.js index 46faf009a8db104ab62c8b68457f36db7956fce3..861cd65b7e3bc19c3899be92eb0c8975d849be22 100644 --- a/packages/uni-cli-shared/lib/preprocess.js +++ b/packages/uni-cli-shared/lib/preprocess.js @@ -5,7 +5,10 @@ const DEFAULT_KEYS = [ 'APP', 'APP-PLUS-NVUE', 'APP-VUE', - 'APP-NVUE' + 'APP-NVUE', + 'APP-ANDROID', + 'APP-IOS', + 'WEB' ] function normalize (name) { @@ -44,14 +47,25 @@ module.exports = function initPreprocess (name, platforms, userDefines = {}) { nvueContext.APP_PLUS = true nvueContext.APP_NVUE = true nvueContext.APP_PLUS_NVUE = true - } + if (process.env.UNI_APP_PLATFORM === 'android') { + defaultContext.APP_ANDROID = true + } else if (process.env.UNI_APP_PLATFORM === 'ios') { + defaultContext.APP_IOS = true + } else { + defaultContext.APP_ANDROID = true + defaultContext.APP_IOS = true + } + } + if (name === 'h5') { + defaultContext.WEB = true + } if (name.startsWith('mp-')) { vueContext.MP = true } if (name.startsWith('app-')) { - vueContext.APP = true + vueContext.APP = true nvueContext.APP = true }