Skip to content

Commit

Permalink
Add htmlChunks configuration item (#159) (#160)
Browse files Browse the repository at this point in the history
* Add htmlChunks configuration item (#159)

* feat(ko): add htmlChunks configuration item

* docs: add htmlChunks to configuration

* docs(changeset): add htmlChunks to configure the chunks of HtmlWebpackPlugin

---------

Co-authored-by: jiming <[email protected]>

* RELEASING: Releasing 1 package(s)

Releases:
  [email protected]

[skip ci]

---------

Co-authored-by: Shawn <[email protected]>
Co-authored-by: jiming <[email protected]>
  • Loading branch information
3 people authored Oct 25, 2023
1 parent 9ff6509 commit 81c8d59
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
6 changes: 6 additions & 0 deletions packages/ko/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ko

## 6.5.10

### Patch Changes

- 63e89263e: add htmlChunks to configure the chunks of HtmlWebpackPlugin

## 6.5.9

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ko/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ko",
"version": "6.5.9",
"version": "6.5.10",
"description": "build & lint library",
"keywords": [
"ko",
Expand Down
1 change: 1 addition & 0 deletions packages/ko/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type IOptions = {
externals?: Record<string, string>;
plugins?: HookOptions[];
htmlTemplate?: string;
htmlChunks?: 'all' | string[];
// style configs
analyzer?: boolean;
extraPostCSSPlugins?: Plugin[];
Expand Down
11 changes: 8 additions & 3 deletions packages/ko/src/webpack/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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$/,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions website/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type IOptions = {
externals?: Record<string, string>; //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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type IOptions = {
externals?: Record<string, string>; // 从输出的Bundle中需要排除的依赖
plugins?: any[]; // ko 内部插件,您可以定义自己的 ko 插件。
htmlTemplate?: string; // 输出 HTML 文件模板
htmlChunks?: 'all' | string[]; // 添加到 HTML 中的 chunk
// 样式配置
analyzer?: boolean; // 显示带有可缩放的交互式树状图的输出文件
extraPostCSSPlugins?: Plugin[]; // 额外的 postcss 插件
Expand Down

0 comments on commit 81c8d59

Please sign in to comment.