-
Notifications
You must be signed in to change notification settings - Fork 137
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
"clean": "rm -rf build && mkdir build", | ||
"relay": "relay-compiler --src ./client --schema server/data/schema.graphql" | ||
}, | ||
|
@@ -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 commentThe 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 commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. @ncrmro and @jkettmann, those are very useful information |
||
"webpack-dev-server": "2.5.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,14 @@ const webpack = require('webpack'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const FaviconsWebpackPlugin = require('favicons-webpack-plugin'); | ||
|
||
let outputPath; | ||
let appEntry; | ||
let devtool; | ||
let plugins; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
appEntry = [path.join(__dirname, 'client/index.js')]; | ||
outputPath = path.join(__dirname, 'build/app'); | ||
devtool = 'source-map'; | ||
plugins = [ | ||
new webpack.optimize.OccurrenceOrderPlugin(), | ||
|
@@ -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 commentThe 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 commentThe 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.
|
||
devtool = 'eval'; | ||
plugins = [ | ||
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.js' }), | ||
|
@@ -66,7 +69,7 @@ module.exports = { | |
vendor: ['react', 'react-dom', 'react-mdl', 'react-relay', 'react-router', 'react-router-relay'] | ||
}, | ||
output: { | ||
path: path.join(__dirname, 'build'), | ||
path: outputPath, | ||
publicPath: '/', | ||
filename: '[name].js' | ||
}, | ||
|
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.