-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Webpack - For Production #129
Comments
There are many ways to go to production, and Webpack is only one of them. If you chose to go with Webpack to build your static assets, the configuration that you see in // In webpack.config.js
module.exports = {
entry: path.resolve(__dirname, 'js', 'app.js'),
eslint: {
configFile: '.eslintrc'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
query: {
stage: 0,
plugins: ['./build/babelRelayPlugin']
}
},
{
test: /\.js$/,
loader: 'eslint'
}
]
},
output: {filename: 'app.js', path: '/'}
} Running From that point, you might want to investigate features like code splitting and multiple entry points to split up your bundles as your app grows. I hope that this gives you a headstart. To learn more about how others are deploying their React applications in production, consider asking around on the Reactiflux Slack. There's a #webpack group in there. You can sign up here: http://www.reactiflux.com/ |
HI @steveluscher |
The part that you show in your original example is creating a development http server. The settings you are passing to As @steveluscher said, you can use Webpack does not provide a production web server, it just bundles your assets together. You must then serve those bundled assets yourself. See this blog post for examples on how to set this up. |
@fortune I brought this up because I read some article saying webpackdevserver is for development environment. Not for production as it will slow down the system. Which I also realise on the star-wars, and treasurehunt, it really take time to start the server for testing purposes. |
Right, Have a look at relay-starter-kit which is a nice starting point for a new relay application. |
@spyalert01 For example, your production
This is assuming you have copied the bundled assets generated by webpack, your |
I see. thanks |
Hi all,
This is my production webpack config:
I am running my build with the following command:
Any help would be appreciated. |
LOL. Wow. The above was working, I just had a typo. 'static', 'dist' should have been 'dist', 'static' |
👍 |
@standardtoaster is there a recipe how to do code splitting and the stuff like this (taken from rsk): import Component from './Component'; // <= breaks code-splitting
const route = {
path: '/component',
queries: {
viewer: Relay.QL`query {
viewer {
${Component.getFragment(..)}
}
}`
},
async action() {
return { title: 'Code-splitting Demo', component: await System.load('./Component') };
}
} |
@standardtoaster correct me if I'm wrong, if you're using code-splitting, you can perform a GraphQL/Relay query only after the component was loaded into run-time? (e.g. you can't download data and some component that requires that data at the same time) |
So far most of the example uses
This is actually run time generation. WebpackDevServer should be more for Development. If we want to have the same for production,
Thanks
The text was updated successfully, but these errors were encountered: