From 7095773854e25fbed2a5fe0ad7f096b9cc395e9d Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Thu, 3 Dec 2020 16:42:23 +0800 Subject: [PATCH] feat(cli): add site.htmlPluginOptions config --- packages/vant-cli/docs/config.md | 7 +++++++ packages/vant-cli/src/config/webpack.site.dev.ts | 3 +++ 2 files changed, 10 insertions(+) diff --git a/packages/vant-cli/docs/config.md b/packages/vant-cli/docs/config.md index 794a71607..ad0abdeaa 100644 --- a/packages/vant-cli/docs/config.md +++ b/packages/vant-cli/docs/config.md @@ -222,6 +222,13 @@ module.exports = { 配置内容参见 [docsearch](https://docsearch.algolia.com/docs/behavior)。 +### site.htmlPluginOptions + +- Type: `object` +- Default: `undefined` + +html-webpack-plugin 的配置项,详见 [Options](https://github.com/jantimon/html-webpack-plugin#options)。 + ## Webpack 通过根目录下的`webpack.config.js`文件可以修改 Webpack 配置,配置内容会通过 [webpack-merge](https://github.com/survivejs/webpack-merge) 合并到最终的配置中。 diff --git a/packages/vant-cli/src/config/webpack.site.dev.ts b/packages/vant-cli/src/config/webpack.site.dev.ts index 0346e1428..48fea0291 100644 --- a/packages/vant-cli/src/config/webpack.site.dev.ts +++ b/packages/vant-cli/src/config/webpack.site.dev.ts @@ -39,6 +39,7 @@ export function getSiteDevBaseConfig(): WebpackConfig { const siteConfig = getSiteConfig(); const title = getTitle(siteConfig); + const { htmlPluginOptions } = vantConfig.site; return merge(baseConfig as any, { entry: { @@ -88,6 +89,7 @@ export function getSiteDevBaseConfig(): WebpackConfig { template: join(__dirname, '../../site/desktop/index.html'), filename: 'index.html', baiduAnalytics, + ...htmlPluginOptions, }), new HtmlWebpackPlugin({ title, @@ -97,6 +99,7 @@ export function getSiteDevBaseConfig(): WebpackConfig { template: join(__dirname, '../../site/mobile/index.html'), filename: 'mobile.html', baiduAnalytics, + ...htmlPluginOptions, }), ], });