mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-06-19 04:18:31 -06:00
Changing server.js to server.jsx
This commit is contained in:
4
src/@types/custom.d.ts
vendored
Normal file
4
src/@types/custom.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
declare module "*.svg" {
|
||||
const content: any;
|
||||
export default content;
|
||||
}
|
9
src/@types/express/index.d.ts
vendored
Normal file
9
src/@types/express/index.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
import * as express from "express"
|
||||
|
||||
declare global {
|
||||
namespace Express {
|
||||
interface Request {
|
||||
hashManifest?: Record<string,any>
|
||||
}
|
||||
}
|
||||
}
|
@ -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}`);
|
||||
});
|
Reference in New Issue
Block a user