diff --git a/examples/ant-design-pro/config/config.ts b/examples/ant-design-pro/config/config.ts index 82972dc7bb4b..9537b4cf3432 100644 --- a/examples/ant-design-pro/config/config.ts +++ b/examples/ant-design-pro/config/config.ts @@ -313,15 +313,28 @@ export default defineConfig({ mfsu: { // esbuild: true, }, - chainWebpack(memo) { + chainWebpack(memo: any) { memo.plugin('monaco-editor').use(MonacoEditorWebpackPlugin, []); return memo; }, - ssr: { - builder: 'webpack', - platform: 'node', - }, - exportStatic: {}, + // openAPI: [ + // { + // requestLibPath: "import { request } from 'umi'", + // // 或者使用在线的版本 + // // schemaPath: "https://gw.alipayobjects.com/os/antfincdn/M%24jrzTTYJN/oneapi.json" + // schemaPath: join(__dirname, 'oneapi.json'), + // mock: false, + // }, + // { + // requestLibPath: "import { request } from 'umi'", + // schemaPath: 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json', + // projectName: 'swagger', + // }, + // ], + // nodeModulesTransform: { + // type: 'none', + // }, + // exportStatic: {}, codeSplitting: { jsStrategy: 'granularChunks', }, diff --git a/packages/bundler-webpack/src/config/ssrPlugin.ts b/packages/bundler-webpack/src/config/ssrPlugin.ts index 21b987744eb5..65ab2ac893a9 100644 --- a/packages/bundler-webpack/src/config/ssrPlugin.ts +++ b/packages/bundler-webpack/src/config/ssrPlugin.ts @@ -23,11 +23,9 @@ const PLUGIN_NAME = 'SSR_PLUGIN'; class SSRPlugin { opts: IOpts; manifest: Map; - isGenManifest: boolean; constructor(opts: IOpts) { this.opts = opts; this.manifest = new Map(); - this.isGenManifest = false; } apply(compiler: Compiler) { // ref: https://github.com/webdeveric/webpack-assets-manifest @@ -72,16 +70,13 @@ class SSRPlugin { 2, ); if ( - (process.env.NODE_ENV === 'production' || - this.opts.userConfig.writeToDisk) && - !this.isGenManifest + process.env.NODE_ENV === 'production' || + this.opts.userConfig.writeToDisk ) { - // 如果已经生成了,就不管了。不然会报错重复添加 compilation.emitAsset( 'build-manifest.json', new sources.RawSource(assetsSource, false), ); - this.isGenManifest = true; } else { const outputPath = compiler.options.output.path!; fsExtra.mkdirpSync(outputPath); diff --git a/packages/preset-umi/src/features/exportStatic/exportStatic.ts b/packages/preset-umi/src/features/exportStatic/exportStatic.ts index 864d3df9dbc4..411a2b44e35d 100644 --- a/packages/preset-umi/src/features/exportStatic/exportStatic.ts +++ b/packages/preset-umi/src/features/exportStatic/exportStatic.ts @@ -31,11 +31,10 @@ function getExportHtmlData(routes: Record): IExportHtmlItem[] { if ( // skip layout !route.isLayout && - route?.path && // skip dynamic route for win, because `:` is not allowed in file name - (!IS_WIN || !route?.path?.includes('/:')) && + (!IS_WIN || !route.path.includes('/:')) && // skip `*` route, because `*` is not working for most site serve services - (!route?.path?.includes('*') || + (!route.path.includes('*') || // except `404.html` is404) ) { diff --git a/packages/server/src/ssr.ts b/packages/server/src/ssr.ts index f5da1e5d6b54..ba26f6f55ccb 100644 --- a/packages/server/src/ssr.ts +++ b/packages/server/src/ssr.ts @@ -204,11 +204,11 @@ export function createMarkupGenerator(opts: CreateRequestHandlerOptions) { html = html.replace( /(<\/head>)/, [ - opts.helmetContext.helmet?.title?.toString(), - opts.helmetContext.helmet?.priority?.toString(), - opts.helmetContext.helmet?.meta?.toString(), - opts.helmetContext.helmet?.link?.toString(), - opts.helmetContext.helmet?.script?.toString(), + opts.helmetContext.helmet.title.toString(), + opts.helmetContext.helmet.priority.toString(), + opts.helmetContext.helmet.meta.toString(), + opts.helmetContext.helmet.link.toString(), + opts.helmetContext.helmet.script.toString(), '$1', ] .filter(Boolean)