diff --git a/plugins/plugin-webpack/plugin.js b/plugins/plugin-webpack/plugin.js index a7f0a40fcb..b8dccf14de 100644 --- a/plugins/plugin-webpack/plugin.js +++ b/plugins/plugin-webpack/plugin.js @@ -177,6 +177,16 @@ function getSplitChunksConfig({numEntries}) { }; } +function getPresetEnvTargets({browserslist}) { + if(Array.isArray(browserslist) || typeof browserslist === "string") { + return browserslist; + } else if(typeof browserslist === "object" && "production" in browserslist) { + return browserslist.production; + } else { + return '>0.75%, not ie 11, not UCAndroid >0, not OperaMini all' + } +} + module.exports = function plugin(config, args = {}) { // Deprecated: args.mode if (args.mode && args.mode !== 'production') { @@ -236,8 +246,7 @@ module.exports = function plugin(config, args = {}) { encoding: 'utf-8', }), ); - const presetEnvTargets = - tempBuildManifest.browserslist || '>0.75%, not ie 11, not UCAndroid >0, not OperaMini all'; + const presetEnvTargets = getPresetEnvTargets(tempBuildManifest) let extendConfig = (cfg) => cfg; if (typeof args.extendConfig === 'function') {