diff --git a/.changeset/five-ghosts-care.md b/.changeset/five-ghosts-care.md new file mode 100644 index 000000000000..a0dc0d074d1d --- /dev/null +++ b/.changeset/five-ghosts-care.md @@ -0,0 +1,7 @@ +--- +'@modern-js/utils': patch +'@modern-js/builder': patch +--- + +feat: align rsbuild config +feat: 对齐 rsbuild 配置 diff --git a/packages/cli/builder/src/plugins/extensionPrefix.ts b/packages/cli/builder/src/plugins/extensionPrefix.ts deleted file mode 100644 index 93611a98523b..000000000000 --- a/packages/cli/builder/src/plugins/extensionPrefix.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { RsbuildPlugin, RsbuildTarget } from '@rsbuild/core'; - -export const pluginExtensionPrefix = ( - prefixInfo: string | Partial>, -): RsbuildPlugin => ({ - name: 'builder:extension-prefix', - - setup(api) { - api.modifyBundlerChain((chain, { target }) => { - // add an extra prefix to all extensions - const prefix = - typeof prefixInfo === 'string' ? prefixInfo : prefixInfo[target]; - - if (prefix) { - const extensions = chain.resolve.extensions.values(); - - chain.resolve.extensions.clear(); - - extensions.forEach(ext => { - chain.resolve.extensions.add(prefix + ext); - chain.resolve.extensions.add(ext); - }); - } - }); - }, -}); diff --git a/packages/cli/builder/src/plugins/mainFields.ts b/packages/cli/builder/src/plugins/mainFields.ts deleted file mode 100644 index 53595b335f53..000000000000 --- a/packages/cli/builder/src/plugins/mainFields.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { RsbuildPlugin, RsbuildTarget } from '@rsbuild/core'; -import type { MainFields } from '../types'; - -export const pluginMainFields = ( - resolveMainFields: MainFields | Partial>, -): RsbuildPlugin => ({ - name: 'builder:main-fields', - - setup(api) { - api.modifyBundlerChain((chain, { target }) => { - const mainFields = Array.isArray(resolveMainFields) - ? resolveMainFields - : resolveMainFields[target]; - - if (mainFields) { - mainFields - .reduce((result: string[], fields) => { - if (Array.isArray(fields)) { - result.push(...fields); - } else { - result.push(fields); - } - return result; - }, [] as string[]) - .forEach(field => { - chain.resolve.mainFields.add(field); - }); - } - }); - }, -}); diff --git a/packages/cli/builder/src/shared/parseCommonConfig.ts b/packages/cli/builder/src/shared/parseCommonConfig.ts index eb41fa63d945..548261e37f1a 100644 --- a/packages/cli/builder/src/shared/parseCommonConfig.ts +++ b/packages/cli/builder/src/shared/parseCommonConfig.ts @@ -68,14 +68,7 @@ export async function parseCommonConfig( ...outputConfig } = {}, html: { outputStructure, appIcon, ...htmlConfig } = {}, - source: { - alias, - globalVars, - resolveMainFields, - resolveExtensionPrefix, - transformImport, - ...sourceConfig - } = {}, + source: { alias, globalVars, transformImport, ...sourceConfig } = {}, dev = {}, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { @@ -166,10 +159,7 @@ export async function parseCommonConfig( html.title ??= ''; - html.appIcon = - typeof appIcon === 'string' - ? { icons: [{ src: appIcon, size: 180 }] } - : appIcon; + html.appIcon = appIcon; extraConfig.tools ??= {}; @@ -237,18 +227,6 @@ export async function parseCommonConfig( ); } - if (resolveMainFields) { - const { pluginMainFields } = await import('../plugins/mainFields'); - rsbuildPlugins.push(pluginMainFields(resolveMainFields)); - } - - if (resolveExtensionPrefix) { - const { pluginExtensionPrefix } = await import( - '../plugins/extensionPrefix' - ); - rsbuildPlugins.push(pluginExtensionPrefix(resolveExtensionPrefix)); - } - if (convertToRem) { const { pluginRem } = await import('@rsbuild/plugin-rem'); rsbuildPlugins.push( diff --git a/packages/cli/builder/src/shared/utils.ts b/packages/cli/builder/src/shared/utils.ts index f3089f790ad1..754e7b497e26 100644 --- a/packages/cli/builder/src/shared/utils.ts +++ b/packages/cli/builder/src/shared/utils.ts @@ -49,11 +49,16 @@ export const isHtmlDisabled = ( ); }; -const DEFAULT_WEB_BROWSERSLIST = ['> 0.01%', 'not dead', 'not op_mini all']; +const DEFAULT_WEB_BROWSERSLIST = [ + 'chrome >= 87', + 'edge >= 88', + 'firefox >= 78', + 'safari >= 14', +]; const DEFAULT_BROWSERSLIST: Record = { web: DEFAULT_WEB_BROWSERSLIST, - node: ['node >= 14'], + node: ['node >= 16'], 'web-worker': DEFAULT_WEB_BROWSERSLIST, }; diff --git a/packages/cli/builder/src/types.ts b/packages/cli/builder/src/types.ts index 8f32dd55ab28..fe4edfd49294 100644 --- a/packages/cli/builder/src/types.ts +++ b/packages/cli/builder/src/types.ts @@ -151,15 +151,6 @@ export type BuilderExtraConfig = { * Define global variables. It can replace expressions like `process.env.FOO` in your code after compile. */ globalVars?: ChainedGlobalVars; - /** - * This configuration will determine which field of `package.json` you use to import the `npm` module. - * Same as the [resolve.mainFields](https://webpack.js.org/configuration/resolve/#resolvemainfields) config of webpack. - */ - resolveMainFields?: MainFields | Partial>; - /** - * Add a prefix to [resolve.extensions](https://webpack.js.org/configuration/resolve/#resolveextensions). - */ - resolveExtensionPrefix?: string | Partial>; }; output?: { /** @@ -200,7 +191,7 @@ export type BuilderExtraConfig = { disableSvgr?: boolean; }; html?: { - appIcon?: string | HtmlConfig['appIcon']; + appIcon?: HtmlConfig['appIcon']; // TODO: need support rsbuild favicon type in server/utils favicon?: string; }; diff --git a/packages/cli/builder/tests/__snapshots__/babel.test.ts.snap b/packages/cli/builder/tests/__snapshots__/babel.test.ts.snap index 23a22fd0e2f1..6fcf37529922 100644 --- a/packages/cli/builder/tests/__snapshots__/babel.test.ts.snap +++ b/packages/cli/builder/tests/__snapshots__/babel.test.ts.snap @@ -36,9 +36,10 @@ exports[`plugin-babel (rspack mode) > should merge environment and shared babel "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -166,9 +167,10 @@ exports[`plugin-babel (rspack mode) > should merge environment and shared babel "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -288,9 +290,10 @@ exports[`plugin-babel (rspack mode) > should not set babel-loader when babel con "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -373,9 +376,10 @@ exports[`plugin-babel (rspack mode) > should set babel-loader when babel config "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -495,9 +499,10 @@ exports[`plugin-babel (rspack mode) > should set babel-loader when environment b "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -617,9 +622,10 @@ exports[`plugin-babel (rspack mode) > should set babel-loader when environment b "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", diff --git a/packages/cli/builder/tests/__snapshots__/default.test.ts.snap b/packages/cli/builder/tests/__snapshots__/default.test.ts.snap index 524e9f2c5ff1..3914d467d980 100644 --- a/packages/cli/builder/tests/__snapshots__/default.test.ts.snap +++ b/packages/cli/builder/tests/__snapshots__/default.test.ts.snap @@ -85,22 +85,10 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -114,17 +102,19 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -166,22 +156,10 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -195,17 +173,19 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -252,9 +232,10 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -319,9 +300,10 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -514,22 +496,10 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -543,17 +513,19 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -612,22 +584,10 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -641,17 +601,19 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -734,22 +696,10 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -763,17 +713,19 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -824,22 +776,10 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -853,17 +793,19 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -922,9 +864,10 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -997,9 +940,10 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -1279,7 +1223,7 @@ exports[`builder rspack > should generator rspack config correctly 1`] = ` }, "target": [ "web", - "browserslist:> 0.01%,not dead,not op_mini all", + "es2017", ], "watchOptions": { "aggregateTimeout": 0, @@ -1433,7 +1377,7 @@ exports[`builder rspack > should generator rspack config correctly when node 1`] "options": { "env": { "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -1493,7 +1437,7 @@ exports[`builder rspack > should generator rspack config correctly when node 1`] "options": { "env": { "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -1869,7 +1813,7 @@ exports[`builder rspack > should generator rspack config correctly when node 1`] "options": { "env": { "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -1940,7 +1884,7 @@ exports[`builder rspack > should generator rspack config correctly when node 1`] "options": { "env": { "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -2252,22 +2196,10 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -2281,17 +2213,19 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -2333,22 +2267,10 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -2362,17 +2284,19 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -2418,9 +2342,10 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -2485,9 +2410,10 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -2680,22 +2606,10 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -2709,17 +2623,19 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -2778,22 +2694,10 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -2807,17 +2711,19 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -2900,22 +2806,10 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -2929,17 +2823,19 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -2990,22 +2886,10 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -3019,17 +2903,19 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -3088,9 +2974,10 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -3163,9 +3050,10 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -3456,7 +3344,7 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`] }, "target": [ "web", - "browserslist:> 0.01%,not dead,not op_mini all", + "es2017", ], "watchOptions": { "aggregateTimeout": 0, @@ -3588,7 +3476,7 @@ exports[`builder rspack > should generator rspack config correctly when service- "env": { "mode": undefined, "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -3649,7 +3537,7 @@ exports[`builder rspack > should generator rspack config correctly when service- "env": { "mode": undefined, "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -4007,7 +3895,7 @@ exports[`builder rspack > should generator rspack config correctly when service- "env": { "mode": undefined, "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -4079,7 +3967,7 @@ exports[`builder rspack > should generator rspack config correctly when service- "env": { "mode": undefined, "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", diff --git a/packages/cli/builder/tests/__snapshots__/environment.test.ts.snap b/packages/cli/builder/tests/__snapshots__/environment.test.ts.snap index 413f8cd4a7af..7869e8437999 100644 --- a/packages/cli/builder/tests/__snapshots__/environment.test.ts.snap +++ b/packages/cli/builder/tests/__snapshots__/environment.test.ts.snap @@ -86,22 +86,10 @@ exports[`builder environment compat > should generator environment config correc "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -115,17 +103,19 @@ exports[`builder environment compat > should generator environment config correc }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -167,22 +157,10 @@ exports[`builder environment compat > should generator environment config correc "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -196,17 +174,19 @@ exports[`builder environment compat > should generator environment config correc }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -253,9 +233,10 @@ exports[`builder environment compat > should generator environment config correc "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -320,9 +301,10 @@ exports[`builder environment compat > should generator environment config correc "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -515,22 +497,10 @@ exports[`builder environment compat > should generator environment config correc "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -544,17 +514,19 @@ exports[`builder environment compat > should generator environment config correc }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -613,22 +585,10 @@ exports[`builder environment compat > should generator environment config correc "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -642,17 +602,19 @@ exports[`builder environment compat > should generator environment config correc }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -735,22 +697,10 @@ exports[`builder environment compat > should generator environment config correc "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -764,17 +714,19 @@ exports[`builder environment compat > should generator environment config correc }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -825,22 +777,10 @@ exports[`builder environment compat > should generator environment config correc "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -854,17 +794,19 @@ exports[`builder environment compat > should generator environment config correc }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -923,9 +865,10 @@ exports[`builder environment compat > should generator environment config correc "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -998,9 +941,10 @@ exports[`builder environment compat > should generator environment config correc "coreJs": "3.46", "mode": "entry", "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "isModule": "unknown", @@ -1260,7 +1204,7 @@ exports[`builder environment compat > should generator environment config correc }, "target": [ "web", - "browserslist:> 0.01%,not dead,not op_mini all", + "es2017", ], "watchOptions": { "aggregateTimeout": 0, @@ -1392,7 +1336,7 @@ exports[`builder environment compat > should generator environment config correc "options": { "env": { "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -1452,7 +1396,7 @@ exports[`builder environment compat > should generator environment config correc "options": { "env": { "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -1828,7 +1772,7 @@ exports[`builder environment compat > should generator environment config correc "options": { "env": { "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -1899,7 +1843,7 @@ exports[`builder environment compat > should generator environment config correc "options": { "env": { "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -2211,7 +2155,7 @@ exports[`builder environment compat > should generator environment config correc "env": { "mode": undefined, "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -2272,7 +2216,7 @@ exports[`builder environment compat > should generator environment config correc "env": { "mode": undefined, "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -2630,7 +2574,7 @@ exports[`builder environment compat > should generator environment config correc "env": { "mode": undefined, "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", @@ -2702,7 +2646,7 @@ exports[`builder environment compat > should generator environment config correc "env": { "mode": undefined, "targets": [ - "node >= 14", + "node >= 16", ], }, "isModule": "unknown", diff --git a/packages/cli/builder/tests/__snapshots__/postcssLegacy.test.ts.snap b/packages/cli/builder/tests/__snapshots__/postcssLegacy.test.ts.snap index 3b1ab22d9d2f..63ef31ccc99b 100644 --- a/packages/cli/builder/tests/__snapshots__/postcssLegacy.test.ts.snap +++ b/packages/cli/builder/tests/__snapshots__/postcssLegacy.test.ts.snap @@ -41,9 +41,10 @@ exports[`lightningcss-loader > should register lightningcss-loader and disable p "options": { "errorRecovery": true, "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, }, @@ -72,9 +73,10 @@ exports[`lightningcss-loader > should register lightningcss-loader and disable p "options": { "errorRecovery": true, "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, }, @@ -129,9 +131,10 @@ exports[`lightningcss-loader > should register lightningcss-loader and postcss-l "options": { "errorRecovery": true, "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, }, @@ -176,9 +179,10 @@ exports[`lightningcss-loader > should register lightningcss-loader and postcss-l "options": { "errorRecovery": true, "targets": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, }, @@ -255,22 +259,10 @@ exports[`plugin-postcssLegacy > should allow tools.postcss to override the plugi "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -284,17 +276,19 @@ exports[`plugin-postcssLegacy > should allow tools.postcss to override the plugi }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -340,22 +334,10 @@ exports[`plugin-postcssLegacy > should allow tools.postcss to override the plugi "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -369,17 +351,19 @@ exports[`plugin-postcssLegacy > should allow tools.postcss to override the plugi }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -450,22 +434,10 @@ exports[`plugin-postcssLegacy > should allow tools.postcss to override the plugi "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -479,17 +451,19 @@ exports[`plugin-postcssLegacy > should allow tools.postcss to override the plugi }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -552,22 +526,10 @@ exports[`plugin-postcssLegacy > should allow tools.postcss to override the plugi "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -581,17 +543,19 @@ exports[`plugin-postcssLegacy > should allow tools.postcss to override the plugi }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -683,22 +647,10 @@ exports[`plugin-postcssLegacy > should allow tools.postcss to override the plugi "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -712,17 +664,19 @@ exports[`plugin-postcssLegacy > should allow tools.postcss to override the plugi }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", @@ -777,22 +731,10 @@ exports[`plugin-postcssLegacy > should allow tools.postcss to override the plugi "Once": [Function], "postcssPlugin": "postcss-flexbugs-fixes", }, - { - "postcssPlugin": "postcss-custom-properties", - "prepare": [Function], - }, - { - "Declaration": [Function], - "postcssPlugin": "postcss-initial", - }, { "Declaration": [Function], "postcssPlugin": "postcss-page-break", }, - { - "Once": [Function], - "postcssPlugin": "postcss-font-variant", - }, { "AtRule": { "custom-media": [Function], @@ -806,17 +748,19 @@ exports[`plugin-postcssLegacy > should allow tools.postcss to override the plugi }, { "browsers": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], "info": [Function], "options": { "flexbox": "no-2009", "overrideBrowserslist": [ - "> 0.01%", - "not dead", - "not op_mini all", + "chrome >= 87", + "edge >= 88", + "firefox >= 78", + "safari >= 14", ], }, "postcssPlugin": "autoprefixer", diff --git a/packages/document/main-doc/docs/en/components/upgrade-browserslist.mdx b/packages/document/main-doc/docs/en/components/upgrade-browserslist.mdx new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/document/main-doc/docs/en/configure/app/html/app-icon.mdx b/packages/document/main-doc/docs/en/configure/app/html/app-icon.mdx index 8cc73f5f89e5..f7ca0b9c0773 100644 --- a/packages/document/main-doc/docs/en/configure/app/html/app-icon.mdx +++ b/packages/document/main-doc/docs/en/configure/app/html/app-icon.mdx @@ -13,7 +13,7 @@ type AppIconItem = { target?: 'apple-touch-icon' | 'web-app-manifest'; }; -type AppIcon = string | { +type AppIcon = { name?: string; icons: AppIconItem[]; filename?: string; @@ -27,28 +27,6 @@ Set the web application icons to display when added to the home screen of a mobi - Generate the web app manifest file and its `icons` field. - Generate the `apple-touch-icon` and `manifest` tags in the HTML file. -### AppIcon string - -The `appIcon` configuration of type `string` is a syntactic sugar for the `object` type. - -```js -export default { - html: { - appIcon: './src/assets/icon.png', - }, -}; -``` - -The above configuration is equivalent to the following configuration: - -```js -export default { - html: { - appIcon: { icons: [{ src: './src/assets/icon.png', size: 180 }] } - }, -}; -``` - import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip'; diff --git a/packages/document/main-doc/docs/en/configure/app/output/inline-scripts.mdx b/packages/document/main-doc/docs/en/configure/app/output/inline-scripts.mdx index 186a485cb2ef..d69772fcf7a0 100644 --- a/packages/document/main-doc/docs/en/configure/app/output/inline-scripts.mdx +++ b/packages/document/main-doc/docs/en/configure/app/output/inline-scripts.mdx @@ -20,7 +20,7 @@ type InlineScripts = }; ``` -- **Default:** `false` +- **Default:** `/builder-runtime([.].+)?\.js$/` Whether to inline output scripts files (.js files) into HTML with `'); -}); diff --git a/tests/e2e/builder/cases/html/cross-origin/src/index.js b/tests/e2e/builder/cases/html/cross-origin/src/index.js deleted file mode 100644 index 4748527e94fa..000000000000 --- a/tests/e2e/builder/cases/html/cross-origin/src/index.js +++ /dev/null @@ -1 +0,0 @@ -console.log('1'); diff --git a/tests/e2e/builder/cases/html/favicon/index.test.ts b/tests/e2e/builder/cases/html/favicon/index.test.ts deleted file mode 100644 index 1091d3388969..000000000000 --- a/tests/e2e/builder/cases/html/favicon/index.test.ts +++ /dev/null @@ -1,66 +0,0 @@ -import path from 'path'; -import { expect, test } from '@playwright/test'; -import { build } from '@scripts/shared'; - -test('should emit local favicon to dist path', async () => { - const builder = await build({ - cwd: __dirname, - entry: { index: path.resolve(__dirname, './src/index.js') }, - builderConfig: { - html: { - favicon: './src/icon.png', - }, - }, - }); - const files = await builder.unwrapOutputJSON(); - - expect( - Object.keys(files).some(file => file.endsWith('/icon.png')), - ).toBeTruthy(); - - const html = - files[Object.keys(files).find(file => file.endsWith('index.html'))!]; - - expect(html).toContain(''); -}); - -test('should apply asset prefix to favicon URL', async () => { - const builder = await build({ - cwd: __dirname, - entry: { index: path.resolve(__dirname, './src/index.js') }, - builderConfig: { - html: { - favicon: './src/icon.png', - }, - output: { - assetPrefix: 'https://www.example.com', - }, - }, - }); - const files = await builder.unwrapOutputJSON(); - - const html = - files[Object.keys(files).find(file => file.endsWith('index.html'))!]; - - expect(html).toContain( - '', - ); -}); - -test('should allow favicon to be a CDN URL', async () => { - const builder = await build({ - cwd: __dirname, - entry: { index: path.resolve(__dirname, './src/index.js') }, - builderConfig: { - html: { - favicon: 'https://foo.com/icon.png', - }, - }, - }); - const files = await builder.unwrapOutputJSON(); - - const html = - files[Object.keys(files).find(file => file.endsWith('index.html'))!]; - - expect(html).toContain(''); -}); diff --git a/tests/e2e/builder/cases/html/favicon/src/icon.png b/tests/e2e/builder/cases/html/favicon/src/icon.png deleted file mode 100644 index be09a3a0ff20..000000000000 Binary files a/tests/e2e/builder/cases/html/favicon/src/icon.png and /dev/null differ diff --git a/tests/e2e/builder/cases/html/favicon/src/index.js b/tests/e2e/builder/cases/html/favicon/src/index.js deleted file mode 100644 index 4748527e94fa..000000000000 --- a/tests/e2e/builder/cases/html/favicon/src/index.js +++ /dev/null @@ -1 +0,0 @@ -console.log('1'); diff --git a/tests/e2e/builder/cases/html/html.test.ts b/tests/e2e/builder/cases/html/html.test.ts index 8c2a93b3fcf8..aa92b4c60a4f 100644 --- a/tests/e2e/builder/cases/html/html.test.ts +++ b/tests/e2e/builder/cases/html/html.test.ts @@ -27,30 +27,11 @@ test.describe('html configure multi', () => { builder.close(); }); - test('mountId', async ({ page }) => { - await page.goto(getHrefByEntryName('main', builder.port)); - - const test = page.locator('#test'); - await expect(test).toHaveText('Hello Builder!'); - }); - test('title default', async ({ page }) => { await page.goto(getHrefByEntryName('main', builder.port)); await expect(page.evaluate(`document.title`)).resolves.toBe(''); }); - - test('inject default (head)', async () => { - const pagePath = join(builder.distPath, 'html/main/index.html'); - const content = await fs.readFile(pagePath, 'utf-8'); - - expect( - /[\s\S]*[\s\S]*<\/head>/.test(content), - ).toBeTruthy(); - expect( - /[\s\S]*[\s\S]*<\/body>/.test(content), - ).toBeFalsy(); - }); }); test.describe('html element set', () => { @@ -72,7 +53,6 @@ test.describe('html element set', () => { description: 'a description of the page', }, inject: 'body', - appIcon: './src/assets/icon.png', favicon: './src/assets/icon.png', }, }, @@ -92,34 +72,6 @@ test.describe('html element set', () => { builder.close(); }); - test('appicon', async () => { - const [, iconRelativePath] = - //.exec(mainContent) || []; - - expect(iconRelativePath).toBeDefined(); - - const iconPath = join(builder.distPath, iconRelativePath); - expect(fs.existsSync(iconPath)).toBeTruthy(); - - // should work on all page - expect( - //.test(fooContent), - ).toBeTruthy(); - }); - - test('favicon', async () => { - const [, iconRelativePath] = - //.exec(mainContent) || []; - - expect(iconRelativePath).toBeDefined(); - - const iconPath = join(builder.distPath, iconRelativePath); - expect(fs.existsSync(iconPath)).toBeTruthy(); - - // should work on all page - expect(//.test(fooContent)).toBeTruthy(); - }); - test('custom inject', async () => { expect( /[\s\S]*[\s\S]*<\/head>/.test(mainContent), @@ -162,40 +114,6 @@ test('custom title', async ({ page }) => { builder.close(); }); -test('template & templateParameters', async ({ page }) => { - const builder = await build({ - cwd: join(fixtures, 'template'), - entry: { - main: join(join(fixtures, 'template'), 'src/index.ts'), - }, - runServer: true, - builderConfig: { - html: { - template: './static/index.html', - templateParameters: { - foo: 'bar', - }, - }, - }, - }); - - await page.goto(getHrefByEntryName('main', builder.port)); - - await expect(page.evaluate(`document.title`)).resolves.toBe( - 'custom template', - ); - - const testTemplate = page.locator('#test-template'); - await expect(testTemplate).toHaveText('xxx'); - - const testEl = page.locator('#test'); - await expect(testEl).toHaveText('Hello Builder!'); - - await expect(page.evaluate(`window.foo`)).resolves.toBe('bar'); - - builder.close(); -}); - test('outputStructrue flat', async ({ page }) => { const builder = await build({ cwd: join(fixtures, 'template'), diff --git a/tests/e2e/builder/cases/html/inject-false/index.test.ts b/tests/e2e/builder/cases/html/inject-false/index.test.ts deleted file mode 100644 index 3c302405a060..000000000000 --- a/tests/e2e/builder/cases/html/inject-false/index.test.ts +++ /dev/null @@ -1,38 +0,0 @@ -import path from 'path'; -import { expect, test } from '@playwright/test'; -import { build } from '@scripts/shared'; - -test('builder injection script order should be as expected', async () => { - const builder = await build({ - cwd: __dirname, - entry: { index: path.resolve(__dirname, './src/index.js') }, - builderConfig: { - html: { - inject: false, - template: './static/index.html', - }, - output: { - assetsRetry: { - inlineScript: false, - }, - disableInlineRuntimeChunk: true, - convertToRem: { - inlineRuntime: false, - }, - }, - }, - }); - const files = await builder.unwrapOutputJSON(); - - const html = - files[Object.keys(files).find(file => file.endsWith('index.html'))!]; - - // assetsRetry => rem => normal resource => template custom resource - expect( - html.indexOf('/js/assets-retry') < html.indexOf('/js/convert-rem'), - ).toBeTruthy(); - expect( - html.indexOf('/js/convert-rem') < html.indexOf('/js/index'), - ).toBeTruthy(); - expect(html.indexOf('/js/index') < html.indexOf('/assets/a.js')).toBeTruthy(); -}); diff --git a/tests/e2e/builder/cases/html/inject-false/src/index.css b/tests/e2e/builder/cases/html/inject-false/src/index.css deleted file mode 100644 index fb41630886f1..000000000000 --- a/tests/e2e/builder/cases/html/inject-false/src/index.css +++ /dev/null @@ -1,3 +0,0 @@ -.test { - font-size: 14px; -} diff --git a/tests/e2e/builder/cases/html/inject-false/src/index.js b/tests/e2e/builder/cases/html/inject-false/src/index.js deleted file mode 100644 index 0a0c568f08e7..000000000000 --- a/tests/e2e/builder/cases/html/inject-false/src/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import './index.css'; - -console.log('1'); diff --git a/tests/e2e/builder/cases/html/inject-false/static/index.html b/tests/e2e/builder/cases/html/inject-false/static/index.html deleted file mode 100644 index 732b16c47547..000000000000 --- a/tests/e2e/builder/cases/html/inject-false/static/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - custom template - <%= htmlWebpackPlugin.tags.headTags %> - - - -
xxx
-
- <%= htmlWebpackPlugin.tags.bodyTags %> - - diff --git a/tests/e2e/builder/cases/html/script-loading/index.test.ts b/tests/e2e/builder/cases/html/script-loading/index.test.ts deleted file mode 100644 index e4af6bb5a7f1..000000000000 --- a/tests/e2e/builder/cases/html/script-loading/index.test.ts +++ /dev/null @@ -1,49 +0,0 @@ -import path from 'path'; -import { expect, test } from '@playwright/test'; -import { build } from '@scripts/shared'; - -test('should apply defer by default', async () => { - const builder = await build({ - cwd: __dirname, - entry: { index: path.resolve(__dirname, './src/index.js') }, - }); - const files = await builder.unwrapOutputJSON(); - const html = - files[Object.keys(files).find(file => file.endsWith('index.html'))!]; - - expect(html).toContain('