Skip to content

Commit

Permalink
support browserslist with modes in plugin-webpack (#1930)
Browse files Browse the repository at this point in the history
  • Loading branch information
Floffah authored Dec 11, 2020
1 parent bbc10be commit b296189
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions plugins/plugin-webpack/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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') {
Expand Down

1 comment on commit b296189

@vercel
Copy link

@vercel vercel bot commented on b296189 Dec 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.