Skip to content

Commit b8f336c

Browse files
timneutkensarunoda
authored andcommitted
Add custom webpack dev middleware config (vercel#1931)
1 parent 3306262 commit b8f336c

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

readme.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,15 @@ In order to extend our usage of `webpack`, you can define a function that extend
682682

683683
module.exports = {
684684
webpack: (config, { dev }) => {
685-
   // Perform customizations to config
686-
   
687-
   // Important: return the modified config
685+
// Perform customizations to webpack config
686+
687+
// Important: return the modified config
688+
return config
689+
},
690+
webpackDevMiddleware: (config) => {
691+
// Perform customizations to webpack dev middleware config
692+
693+
// Important: return the modified config
688694
return config
689695
}
690696
}

server/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const cache = new Map()
55

66
const defaultConfig = {
77
webpack: null,
8+
webpackDevMiddleware: null,
89
poweredByHeader: true,
910
distDir: '.next',
1011
assetPrefix: ''

server/hot-reloader.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,21 @@ export default class HotReloader {
138138
}
139139
} : {}
140140

141-
this.webpackDevMiddleware = webpackDevMiddleware(compiler, {
141+
let webpackDevMiddlewareConfig = {
142142
publicPath: '/_next/webpack/',
143143
noInfo: true,
144144
quiet: true,
145145
clientLogLevel: 'warning',
146146
watchOptions: { ignored },
147147
...windowsSettings
148-
})
148+
}
149+
150+
if (this.config.webpackDevMiddleware) {
151+
console.log('> Using "webpackDevMiddleware" config function defined in next.config.js.')
152+
webpackDevMiddlewareConfig = this.config.webpackDevMiddleware(webpackDevMiddlewareConfig)
153+
}
154+
155+
this.webpackDevMiddleware = webpackDevMiddleware(compiler, webpackDevMiddlewareConfig)
149156

150157
this.webpackHotMiddleware = webpackHotMiddleware(compiler, {
151158
path: '/_next/webpack-hmr',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy