diff --git a/docs/docs/blog/legacy-browser.en-US.md b/docs/docs/blog/legacy-browser.en-US.md index e403e2ec7078..f1c92647e2d1 100644 --- a/docs/docs/blog/legacy-browser.en-US.md +++ b/docs/docs/blog/legacy-browser.en-US.md @@ -9,7 +9,7 @@ group: ## 默认兼容说明 -Umi 4 默认不支持 IE ,编译兼容目标 `targets` 为 `chrome: 40` ,如需调整,请指定明确的 [targets](../docs/api/config#targets) : +Umi 4 默认不支持 IE ,编译兼容目标 `targets` 为 `{}` ,如需调整,请指定明确的 [targets](../docs/api/config#targets) : ```ts // .umirc.ts diff --git a/docs/docs/blog/legacy-browser.md b/docs/docs/blog/legacy-browser.md index 8bdfbf2c6679..e37bb3a8204f 100644 --- a/docs/docs/blog/legacy-browser.md +++ b/docs/docs/blog/legacy-browser.md @@ -9,7 +9,7 @@ group: ## 默认兼容说明 -Umi 4 默认不支持 IE ,编译兼容目标 `targets` 为 `chrome: 40` ,如需调整,请指定明确的 [targets](../docs/api/config#targets) : +Umi 4 默认不支持 IE ,编译兼容目标 `targets` 为 `{}` ,如需调整,请指定明确的 [targets](../docs/api/config#targets) : ```ts // .umirc.ts diff --git a/docs/docs/docs/api/config.md b/docs/docs/docs/api/config.md index 91eacf3c23ea..cb2831cb87c6 100644 --- a/docs/docs/docs/api/config.md +++ b/docs/docs/docs/api/config.md @@ -1467,10 +1467,12 @@ import SmileUrl, { ReactComponent as SvgSmile } from './smile.svg'; ## targets - 类型:`object` -- 默认值:`{ chrome: 40 }` +- 默认值:`{}` 配置需要兼容的浏览器最低版本。Umi 会根据这个自定引入 polyfill、配置 autoprefixer 和做语法转换等。 +如果你不需要兼容早期浏览器,减少产物构建尺寸, 请将 `targets` 配置为 `{chrome: "80"}`。 + 示例, ```js diff --git a/packages/bundler-webpack/client/constants.js b/packages/bundler-webpack/client/constants.js index 2bce2281d178..4eb23e386166 100644 --- a/packages/bundler-webpack/client/constants.js +++ b/packages/bundler-webpack/client/constants.js @@ -11,9 +11,7 @@ var MESSAGE_TYPE = /* @__PURE__ */ ((MESSAGE_TYPE2) => { MESSAGE_TYPE2["invalid"] = "invalid"; return MESSAGE_TYPE2; })(MESSAGE_TYPE || {}); -var DEFAULT_BROWSER_TARGETS = { - chrome: 40 -}; +var DEFAULT_BROWSER_TARGETS = {}; var DEFAULT_ESBUILD_TARGET_KEYS = [ "chrome", "firefox", diff --git a/packages/bundler-webpack/src/config/compressPlugin.ts b/packages/bundler-webpack/src/config/compressPlugin.ts index 971021e13670..36b684eda0ba 100644 --- a/packages/bundler-webpack/src/config/compressPlugin.ts +++ b/packages/bundler-webpack/src/config/compressPlugin.ts @@ -33,7 +33,7 @@ export async function addCompressPlugin(opts: IOpts) { // esbuild transform only allow `string[]` as target const esbuildTarget = getEsBuildTarget({ - targets: { chrome: '80' }, + targets: userConfig.targets || {}, jsMinifier, }); // 提升 esbuild 压缩产物的兼容性,比如不出现 ?? 这种语法 diff --git a/packages/bundler-webpack/src/constants.ts b/packages/bundler-webpack/src/constants.ts index d4a75b03f98e..ecb3761a69ff 100644 --- a/packages/bundler-webpack/src/constants.ts +++ b/packages/bundler-webpack/src/constants.ts @@ -11,9 +11,7 @@ export enum MESSAGE_TYPE { invalid = 'invalid', } -export const DEFAULT_BROWSER_TARGETS = { - chrome: 40, -}; +export const DEFAULT_BROWSER_TARGETS = {}; export const DEFAULT_ESBUILD_TARGET_KEYS = [ 'chrome',