Skip to content

Commit

Permalink
Add universal to examples. Update webpack config to match reduxjs#626.
Browse files Browse the repository at this point in the history
  • Loading branch information
timdorr committed Aug 27, 2015
1 parent 4d5d2d5 commit ba8529f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
20 changes: 20 additions & 0 deletions docs/introduction/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ It covers:
* Caching responses and showing a spinner while data is fetching;
* Invalidating the cached data.

## Universal

Run the [Universal](https://github.com/rackt/redux/tree/master/examples/universal) example:

```
git clone https://github.com/rackt/redux.git
cd redux/examples/universal
npm install
npm start & npm run client
open http://localhost:8080/
```

It covers:

* [Universal rendering](/docs/recipes/ServerRendering.md) with Redux and React
* Prefetching state based on input and via asynchronous fetches.
* Passing state from the server to the client

## Real World

Run the [Real World](https://github.com/rackt/redux/tree/master/examples/real-world) example:
Expand Down
26 changes: 16 additions & 10 deletions examples/universal/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,28 @@ module.exports = {
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
resolve: {
alias: {
'redux': path.join(__dirname, '..', '..', 'src')
},
extensions: ['', '.js']
},
module: {
loaders: [{
test: /\.js$/,
loaders: ['react-hot', 'babel?optional=runtime'],
exclude: /node_modules/,
include: __dirname
}, {
test: /\.js$/,
loaders: ['babel'],
include: path.join(__dirname, '..', '..', 'src')
}]
}
};

// When inside Redux repo, prefer src to compiled version.
// You can safely delete these lines in your project.
var reduxSrc = path.join(__dirname, '..', '..', 'src');
var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules');
var fs = require('fs');
if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {
// Resolve Redux to source
module.exports.resolve = { alias: { 'redux': reduxSrc } };
// Compile Redux from source
module.exports.module.loaders.push({
test: /\.js$/,
loaders: ['babel'],
include: reduxSrc
});
}

0 comments on commit ba8529f

Please sign in to comment.