Skip to content

Commit

Permalink
Remove proxy() from the dev-server block (#251)
Browse files Browse the repository at this point in the history
* Remove proxy() from the dev-server block

* Update readme
  • Loading branch information
Vlad Zhukov authored and andywer committed Feb 9, 2018
1 parent fc6b905 commit d84ddd2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 32 deletions.
6 changes: 5 additions & 1 deletion packages/dev-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# @webpack-blocks/dev-server - Changelog

## Next version

- Removed `proxy()` ([#251](https://github.com/andywer/webpack-blocks/pull/251))

## 1.0.0-rc

- Removed `reactHot` ([#214](https://github.com/andywer/webpack-blocks/pull/214))
- Removed `reactHot()` ([#214](https://github.com/andywer/webpack-blocks/pull/214))

## 1.0.0-beta.3

Expand Down
13 changes: 7 additions & 6 deletions packages/dev-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ module.exports = createConfig([
// use only if `NODE_ENV === 'development'`:
env('development', [
devServer({
// Show full-screen overlay in the browser on compiler errors or warnings
overlay: true,
}),
// if you need to proxy API requests:
devServer.proxy({
'/api': { target: 'http://localhost:3000' }
// Show full-screen overlay in the browser on compiler errors or warnings
overlay: true,

// If you need to proxy API requests:
proxy: {
'/api': { target: 'http://localhost:3000' },
},
}),
])
])
Expand Down
20 changes: 1 addition & 19 deletions packages/dev-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@

module.exports = devServer

devServer.proxy = proxy

/**
* @param {object} [options] See https://webpack.github.io/docs/configuration.html#devserver
* @param {bool} [options.historyApiFallback]
* @param {bool} [options.hot]
* @param {bool} [options.inline]
* @param {object} [options] See https://webpack.js.org/configuration/dev-server/
* @param {string|string[]} [entry]
* @return {Function}
*/
Expand Down Expand Up @@ -72,16 +67,3 @@ function addDevEntryToAll (presentEntryPoints, devServerEntry) {

return newEntryPoints
}

/**
* @param {object} proxyRoutes { <path>: <target URL> }
* @return {Function}
* @see http://webpack.github.io/docs/webpack-dev-server.html#proxy
*/
function proxy (proxyRoutes) {
return (context, util) => util.merge({
devServer: {
proxy: proxyRoutes
}
})
}
7 changes: 4 additions & 3 deletions packages/sample-app/webpack.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ const webpack = require('webpack')

const developmentConfig = () => group([
sourceMaps(),
devServer(),
devServer.proxy({
'/api/*': { target: 'http://localhost:4000' }
devServer({
proxy: {
'/api/*': { target: 'http://localhost:4000' }
}
}),
performance({
// Increase performance budget thresholds for development mode
Expand Down
7 changes: 4 additions & 3 deletions packages/webpack/__tests__/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ test('complete webpack config creation', t => {
setOutput('./build/bundle.js'),
babel(),
sourceMaps(),
devServer(),
devServer.proxy({
'/api/*': { target: 'http://localhost:8080' }
devServer({
proxy: {
'/api/*': { target: 'http://localhost:8080' }
}
}),
match('*.scss', [
css.modules({
Expand Down

0 comments on commit d84ddd2

Please sign in to comment.