Changing server.js to server.jsx

This commit is contained in:
2022-05-24 13:49:35 +00:00
parent ca1870c64b
commit d0259f13b1
7 changed files with 43 additions and 8 deletions

4
src/@types/custom.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
declare module "*.svg" {
const content: any;
export default content;
}

9
src/@types/express/index.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
import * as express from "express"
declare global {
namespace Express {
interface Request {
hashManifest?: Record<string,any>
}
}
}

View File

@ -31,10 +31,11 @@ const routesUrls = routes.map( route => route.path);
const app = express();
if(env === 'development'){
// @ts-ignore:next-line
const compiler = webpack(webpackConfig);
const serverConfig = {
serverSideRender: true,
publicPath: webpackConfig.output.publicPath,
publicPath: webpackConfig.output?.publicPath,
};
app
@ -101,6 +102,7 @@ const renderApp = (req, res, next) => {
const store = setStore({ initialState });
const preloadedState = store.getState();
const html = renderToString(
// @ts-ignore:next-line
<Provider store={store}>
<StaticRouter location={req.url}>
<App />
@ -116,7 +118,6 @@ app
.get('*', renderApp);
app.listen(port, (err) => {
if(err) console.error(err);
else console.log(`Server running on port ${port}`);
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});