Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert: "fix(ssr): support ant design pro ssr (#11702)" #11854

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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