Conversation
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.
erichulburd
left a comment
There was a problem hiding this comment.
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: [ |
There was a problem hiding this comment.
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' | ||
| ] |
There was a problem hiding this comment.
Does this create a css file?
| 'sass-loader?outputStyle=expanded&sourceMap=true&sourceMapContents=true' | ||
| ] | ||
| }, { | ||
| test: /\.json$/, |
There was a problem hiding this comment.
You can combine these with
test: /\.s?css$/| "url-loader": "0.5.x", | ||
| "webpack": "1.12.9", | ||
| "webpack": "^2.1.0-beta.25", | ||
| "webpack-dev-server": "1.14.0" |
There was a problem hiding this comment.
This is necessary for universal webpack?
| @@ -0,0 +1,7 @@ | |||
| import Server from "./server/config/production/server"; | |||
|
|
|||
There was a problem hiding this comment.
just name run-production.
There was a problem hiding this comment.
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'; | ||
|
|
There was a problem hiding this comment.
You shouldn't use these imports here - they should go in server base are called in ServerBase#config.
| <script src="/assets/style.js"></script> | ||
| <% }else { %> | ||
| <script src="/assets/app.js"></script> | ||
| <script src="/assets/style.js"></script> |
There was a problem hiding this comment.
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` | ||
| } |
There was a problem hiding this comment.
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}`); | ||
| }); | ||
| } |
There was a problem hiding this comment.
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.