diff --git a/packages/ko/CHANGELOG.md b/packages/ko/CHANGELOG.md index 53a6d8ca..d9decc4e 100644 --- a/packages/ko/CHANGELOG.md +++ b/packages/ko/CHANGELOG.md @@ -1,5 +1,11 @@ # ko +## 6.5.10 + +### Patch Changes + +- 63e89263e: add htmlChunks to configure the chunks of HtmlWebpackPlugin + ## 6.5.9 ### Patch Changes diff --git a/packages/ko/package.json b/packages/ko/package.json index 1b5e1fdc..71dd0149 100644 --- a/packages/ko/package.json +++ b/packages/ko/package.json @@ -1,6 +1,6 @@ { "name": "ko", - "version": "6.5.9", + "version": "6.5.10", "description": "build & lint library", "keywords": [ "ko", diff --git a/packages/ko/src/types.ts b/packages/ko/src/types.ts index 9e01475e..6d27f0d9 100644 --- a/packages/ko/src/types.ts +++ b/packages/ko/src/types.ts @@ -15,6 +15,7 @@ export type IOptions = { externals?: Record; plugins?: HookOptions[]; htmlTemplate?: string; + htmlChunks?: 'all' | string[]; // style configs analyzer?: boolean; extraPostCSSPlugins?: Plugin[]; diff --git a/packages/ko/src/webpack/plugins.ts b/packages/ko/src/webpack/plugins.ts index 82165ca2..5bfa7782 100644 --- a/packages/ko/src/webpack/plugins.ts +++ b/packages/ko/src/webpack/plugins.ts @@ -16,11 +16,18 @@ function getPlugins(opts: IWebpackOptions) { const { isProd, htmlTemplate, + htmlChunks, copy, analyzer, autoPolyfills, serve: { host, port, compilationSuccessInfo }, } = opts; + const htmlOptions: HtmlWebpackPlugin.Options = { + template: htmlTemplate, + }; + if (htmlChunks) { + htmlOptions.chunks = htmlChunks; + } return [ new IgnorePlugin({ resourceRegExp: /^\.\/locale$/, @@ -71,9 +78,7 @@ function getPlugins(opts: IWebpackOptions) { chunkFilename: 'css/[id].[contenthash].css', }), new CaseSensitivePathsPlugin(), - new HtmlWebpackPlugin({ - template: htmlTemplate, - }), + new HtmlWebpackPlugin(htmlOptions), copy && new CopyWebpackPlugin({ patterns: copy, diff --git a/website/docs/configuration.md b/website/docs/configuration.md index d6cf7588..b2a4d6e5 100644 --- a/website/docs/configuration.md +++ b/website/docs/configuration.md @@ -18,6 +18,7 @@ export type IOptions = { externals?: Record; //excluding dependencies from the output bundles plugins?: any[]; // ko internal plugins, you can define your own plugin of ko. htmlTemplate?: string; //output html file template + htmlChunks?: 'all' | string[]; // add only some chunks to html // style configs analyzer?: boolean; // show output files with an interactive zoomable treemap extraPostCSSPlugins?: Plugin[]; // extra post css plugins diff --git a/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/configuration.md b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/configuration.md index 1eab2c51..0ffdb853 100644 --- a/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/configuration.md +++ b/website/i18n/zh-CN/docusaurus-plugin-content-docs/current/configuration.md @@ -18,6 +18,7 @@ export type IOptions = { externals?: Record; // 从输出的Bundle中需要排除的依赖 plugins?: any[]; // ko 内部插件,您可以定义自己的 ko 插件。 htmlTemplate?: string; // 输出 HTML 文件模板 + htmlChunks?: 'all' | string[]; // 添加到 HTML 中的 chunk // 样式配置 analyzer?: boolean; // 显示带有可缩放的交互式树状图的输出文件 extraPostCSSPlugins?: Plugin[]; // 额外的 postcss 插件