Skip to content

Commit

Permalink
docs(examples): add an example
Browse files Browse the repository at this point in the history
Add an example of a webpack config taken from a [React Hot Loader 3](gaearon/react-hot-boilerplate#61) PR as an example implementation of it.

�enter the commit message for your changes. Lines starting
  • Loading branch information
Breno Calazans committed Aug 15, 2016
1 parent 7900d99 commit c2e2ffe
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion other/EXAMPLES.md
@@ -1,3 +1,59 @@
# Examples

There's nothing here! [But PRs are welcome!](http://makeapullrequest.com)
## React Hot Loader with `webpack-config-utils`

```js
const path = require('path')
const webpack = require('webpack')
const {getIfUtils, removeEmpty} = require('webpack-config-utils')

const {ifDevelopment, ifProduction} = getIfUtils(process.env.NODE_ENV)

module.exports = {
devtool: 'eval',
entry: removeEmpty([
...ifDevelopment([
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'react-hot-loader/patch',
]),
'./index'
]),
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/'
},
plugins: removeEmpty([
new webpack.optimize.OccurrenceOrderPlugin(),
...ifDevelopment([
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
]),
...ifProduction([
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': '"production"',
},
}),
new webpack.optimize.UglifyJsPlugin({compressor: {warnings: false}}),
]),
]),
module: {
loaders: [{
test: /\.js$/,
loaders: ['babel'],
exclude: /node_modules/,
include: __dirname
}, {
test: /\.js$/,
loaders: ['babel'],
include: path.join(__dirname, '..', '..', 'src')
}, {
test: /\.css?$/,
loaders: ['style', 'raw'],
include: __dirname
}]
}
}
```

0 comments on commit c2e2ffe

Please sign in to comment.