Skip to content

Commit

Permalink
docs(examples): add an example (#4)
Browse files Browse the repository at this point in the history
* docs(examples): add an example

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

* docs(readme): add brenoc as a contributor
  • Loading branch information
klzns authored and Kent C. Dodds committed Aug 15, 2016
1 parent 7900d99 commit 79c5127
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
"infra",
"test"
]
},
{
"login": "brenoc",
"name": "Breno Calazans",
"avatar_url": "https://avatars.githubusercontent.com/u/284515?v=3",
"profile": "https://twitter.com/breno_calazans",
"contributions": [
"example"
]
}
]
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Utilities to help your webpack config be easier to read
[![downloads][downloads-badge]][npm-stat]
[![MIT License][license-badge]][LICENSE]

[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors)
[![PRs Welcome][prs-badge]][prs]
[![Donate][donate-badge]][donate]
[![Code of Conduct][coc-badge]][coc]
Expand Down Expand Up @@ -123,8 +123,8 @@ a few another helpful utility: [`webpack-combine-loaders`](https://www.npmjs.com
Thanks goes to these people ([emoji key][emojis]):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](https://kentcdodds.com)<br />[💻](https://github.com/kentcdodds/webpack-config-utils/commits?author=kentcdodds) [📖](https://github.com/kentcdodds/webpack-config-utils/commits?author=kentcdodds) 💡 🚇 [⚠️](https://github.com/kentcdodds/webpack-config-utils/commits?author=kentcdodds) |
| :---: |
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](https://kentcdodds.com)<br />[💻](https://github.com/kentcdodds/webpack-config-utils/commits?author=kentcdodds) [📖](https://github.com/kentcdodds/webpack-config-utils/commits?author=kentcdodds) 💡 🚇 [⚠️](https://github.com/kentcdodds/webpack-config-utils/commits?author=kentcdodds) | [<img src="https://avatars.githubusercontent.com/u/284515?v=3" width="100px;"/><br /><sub>Breno Calazans</sub>](https://twitter.com/breno_calazans)<br />💡 |
| :---: | :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors][all-contributors] specification. Contributions of any kind welcome!
Expand Down
58 changes: 57 additions & 1 deletion other/EXAMPLES.md
Original file line number Diff line number Diff line change
@@ -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 79c5127

Please sign in to comment.