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
Fixed webpack setup to seperate compilated client and server code #95
Conversation
Thanks @jkettmann for the awesome PR. Could you change the branch to |
@lvarayut Yes, of course. Can you check your heroku deploy? Not sure if I broke that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 , just left some curious comments 😃
package.json
Outdated
@@ -97,7 +97,7 @@ | |||
"react-router-relay": "^0.14.0", | |||
"style-loader": "^0.18.2", | |||
"url-loader": "^0.5.9", | |||
"webpack": "^3.0.0", | |||
"webpack": "2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain why do you downgrade the version of webpack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I couldn't start with webpack 3. Doesn't have anything to do with this issue though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jkettmann Also having trouble starting new webpack 3 something along these lines?
ERROR in TypeError: Cannot read property 'request' of undefined
- ExternalModuleFactoryPlugin.js:37 handleExternals
[relay-fullstack]/[html-webpack-plugin]/[webpack]/lib/ExternalModuleFactoryP lugin.js:37:33
....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ncrmro and @jkettmann, those are very useful information
package.json
Outdated
@@ -9,7 +9,7 @@ | |||
"build-server": "cross-env NODE_ENV=production ./node_modules/.bin/babel ./server --out-dir ./build", | |||
"lint": "eslint client server", | |||
"flow": "flow", | |||
"heroku-postbuild": "cross-env NODE_ENV=production webpack --config webpack.config.js && cross-env NODE_ENV=production ./node_modules/.bin/babel ./server --out-dir ./lib", | |||
"heroku-postbuild": "cross-env NODE_ENV=production webpack --config webpack.config.js && cross-env NODE_ENV=production ./node_modules/.bin/babel ./server --out-dir ./build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to change the output path of the Heroku app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. This is not necessary.
webpack.config.js
Outdated
@@ -41,6 +43,7 @@ if (process.env.NODE_ENV === 'production') { | |||
'webpack-dev-server/client?http://localhost:3000', | |||
'webpack/hot/only-dev-server' | |||
]; | |||
outputPath = path.join(__dirname, 'app'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to use the different path for the development environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right again. Is the contentBase and static server in server/index.js necessary (if I remove them everything seems to be still working). I guess that's why I used a different path for development.
const relayServer = new WebpackDevServer(webpack(webpackConfig), {
contentBase: '/build/',
...
relayServer.use('/', express.static(path.join(__dirname, '../build/app')));
@lvarayut I removed the unnecessesary changes. |
Thanks @jkettmann 👍 |
Changed build directories for client and server.
server -> build
client -> build/app
build/app is exposed via express.static, thus only client side code can be accessed publicly
Closes #94