forked from kentcdodds/webpack-config-utils
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}] | ||
} | ||
} | ||
``` |