From bd4b3b80da48286dcc74a1af498f59f41f38c826 Mon Sep 17 00:00:00 2001 From: winixt Date: Fri, 26 Aug 2022 15:22:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/plugin/scripts/compiler.js | 2 +- .../src/commands/build/getBuildConfig.js | 16 ++++++++++++++-- .../src/plugins/features/targets.js | 14 ++++++++++---- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/packages/create-fes-app/templates/plugin/scripts/compiler.js b/packages/create-fes-app/templates/plugin/scripts/compiler.js index 2d142b71..ee1aeb09 100644 --- a/packages/create-fes-app/templates/plugin/scripts/compiler.js +++ b/packages/create-fes-app/templates/plugin/scripts/compiler.js @@ -32,7 +32,7 @@ function transformBrowserCode(code) { { modules: false, useBuiltIns: false, - targets: { chrome: '51' }, + targets: { chrome: '64' }, }, ], ], diff --git a/packages/fes-builder-vite/src/commands/build/getBuildConfig.js b/packages/fes-builder-vite/src/commands/build/getBuildConfig.js index 51096c0a..60a7c68e 100644 --- a/packages/fes-builder-vite/src/commands/build/getBuildConfig.js +++ b/packages/fes-builder-vite/src/commands/build/getBuildConfig.js @@ -1,6 +1,17 @@ +import { splitVendorChunkPlugin } from 'vite'; import legacy from '@vitejs/plugin-legacy'; import { getInnerCommonConfig } from '../../common/getConfig'; +function getEsbuildTarget(targets) { + const result = []; + ['chrome', 'edge', 'firefox', 'hermes', 'ios', 'node', 'opera', 'rhino', 'safari'].forEach((key) => { + if (targets[key]) { + result.push(`${key}${targets[key]}`); + } + }); + return result; +} + export default async (api) => { const { deepmerge, getTargetsAndBrowsersList } = api.utils; @@ -24,14 +35,15 @@ export default async (api) => { plugins: [ legacy({ modernPolyfills: true, + renderLegacyChunks: false, targets, }), + splitVendorChunkPlugin(), ], build: { ...build, - minify: 'terser', terserOptions: build.terserOptions || api.config.terserOptions, - target: build.target || 'es2015', + target: build.target || getEsbuildTarget(targets), outDir: build.outDir || api.config.outputPath || 'dist', assetsInlineLimit: build.assetsInlineLimit || api.config.inlineLimit || 8192, }, diff --git a/packages/fes-preset-built-in/src/plugins/features/targets.js b/packages/fes-preset-built-in/src/plugins/features/targets.js index 03b6ddd5..5fc55100 100644 --- a/packages/fes-preset-built-in/src/plugins/features/targets.js +++ b/packages/fes-preset-built-in/src/plugins/features/targets.js @@ -3,10 +3,16 @@ export default (api) => { key: 'targets', config: { default: { - chrome: 56, - firefox: 67, - safari: 10, - edge: 13, + android: '61.0.0', + chrome: '61.0.0', + edge: '16.0.0', + firefox: '60.0.0', + ios: '10.3.0', + node: '13.2.0', + opera: '48.0.0', + safari: '10.1.0', + samsung: '8.2.0', + browsers: ['defaults and not chrome < 61'], }, schema(joi) { return joi.object();