Skip to content

Isomorphic render#2

Open
DKbyo wants to merge 5 commits intomasterfrom
isomorphic_assets
Open

Isomorphic render#2
DKbyo wants to merge 5 commits intomasterfrom
isomorphic_assets

Conversation

@DKbyo
Copy link
Copy Markdown
Contributor

@DKbyo DKbyo commented Sep 29, 2016

  • Added new scripts to webpack server and client
  • Separated the WebPackDevServer and react server, only for development.
  • Needs npm install -g npm-run-all in order to build client and server.
  • Fix production local
  • Design mode works without server render

* Added new scripts to build server and client
* Separated the web pack server and react server, this will be only for development.
* INeeded npm install -g npm-run-all in order to build client and server.
Copy link
Copy Markdown
Collaborator

@erichulburd erichulburd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see comments below.

Let's put this PR on hold for now. I need some time to dig through it more thoroughly and more explicitly lay out the use case for universal-webpack.

Essentially, just need to make sure React Templates are compiled on server through webpack - that's it.

Additionally, in production we will want to build out babel-node, which you said this accomplishes.

Let me try to implement this for another project so I can get a better feel for what you did here.

includePaths: [CLIENT, ROOT + '/node_modules']
},
},*/
plugins: [
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete code and rely on git history rather comment out.

'css-loader?importLoaders=2&sourceMap',
'postcss-loader',
'sass-loader?outputStyle=expanded&sourceMap=true&sourceMapContents=true'
]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this create a css file?

'sass-loader?outputStyle=expanded&sourceMap=true&sourceMapContents=true'
]
}, {
test: /\.json$/,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can combine these with

test: /\.s?css$/

Comment thread package.json
"url-loader": "0.5.x",
"webpack": "1.12.9",
"webpack": "^2.1.0-beta.25",
"webpack-dev-server": "1.14.0"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary for universal webpack?

Comment thread run-pro.js
@@ -0,0 +1,7 @@
import Server from "./server/config/production/server";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just name run-production.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just use one file: run.js and then call

const Server = require(`.server/config/${process.env.NODE_ENV}}/server`);

import favicon from 'serve-favicon';
import logger from 'morgan';
import Backend from 'i18next-node-fs-backend';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't use these imports here - they should go in server base are called in ServerBase#config.

Comment thread server/views/index.ejs
<script src="/assets/style.js"></script>
<% }else { %>
<script src="/assets/app.js"></script>
<script src="/assets/style.js"></script>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In production we will definitely want to use ExtractTextPlugin so we can server a stylesheet without compiling with JS.

{
input: './run-pro.js',
output: `./build/server/server.js`
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again I'd prefer to combine these into a single file and use the env variable to require the correct Server class.

console.info(`App is now running on http://localhost:${APP_PORT}`);
console.info(`WebpackDevServer is now running on http://localhost:${APP_PORT}`);
});
}
Copy link
Copy Markdown
Collaborator

@erichulburd erichulburd Oct 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about the role of server.page.js and server.js. What is the role of each server?

serverRenderable will render React on the server and ServerBase will serve static assets, read cookies, etc - so I don't think there is a case where we will need both.

@erichulburd
Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants