Skip to content

Commit

Permalink
revert: "fix(ssr): support ant design pro ssr (#11702)" (#11854)
Browse files Browse the repository at this point in the history
This reverts commit a830383.
  • Loading branch information
PeachScript committed Nov 9, 2023
1 parent d894d0c commit 60896f5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
25 changes: 19 additions & 6 deletions examples/ant-design-pro/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
9 changes: 2 additions & 7 deletions packages/bundler-webpack/src/config/ssrPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ const PLUGIN_NAME = 'SSR_PLUGIN';
class SSRPlugin {
opts: IOpts;
manifest: Map<string, string>;
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
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions packages/preset-umi/src/features/exportStatic/exportStatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ function getExportHtmlData(routes: Record<string, IRoute>): 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)
) {
Expand Down
10 changes: 5 additions & 5 deletions packages/server/src/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 60896f5

Please sign in to comment.