File tree 1 file changed +42
-0
lines changed
src/content/configuration
1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -1551,6 +1551,48 @@ module.exports = {
1551
1551
};
1552
1552
```
1553
1553
1554
+ ## devServer.setupMiddlewares
1555
+
1556
+ ` function (middlewares, devServer) `
1557
+
1558
+ <Badge text = " v4.7.0+" />
1559
+
1560
+ Provides the ability to execute a custom function and apply custom middleware(s).
1561
+
1562
+ ** webpack.config.js**
1563
+
1564
+ ``` javascript
1565
+ module .exports = {
1566
+ // ...
1567
+ devServer: {
1568
+ setupMiddlewares : (middlewares , devServer ) => {
1569
+ if (! devServer) {
1570
+ throw new Error (' webpack-dev-server is not defined' );
1571
+ }
1572
+
1573
+ devServer .app .get (' /setup-middleware/some/path' , (_ , response ) => {
1574
+ response .send (' setup-middlewares option GET' );
1575
+ });
1576
+
1577
+ middlewares .push ({
1578
+ name: ' hello-world-test-one' ,
1579
+ // `path` is optional
1580
+ path: ' /foo/bar' ,
1581
+ middleware : (req , res ) => {
1582
+ res .send (' Foo Bar!' );
1583
+ },
1584
+ });
1585
+
1586
+ middlewares .push ((req , res ) => {
1587
+ res .send (' Hello World!' );
1588
+ });
1589
+
1590
+ return middlewares;
1591
+ },
1592
+ },
1593
+ };
1594
+ ```
1595
+
1554
1596
## devServer.static
1555
1597
1556
1598
` boolean ` ` string ` ` [string] ` ` object ` ` [object] `
You can’t perform that action at this time.
0 commit comments