Commit b8f336c7 authored by Tim Neutkens's avatar Tim Neutkens Committed by Arunoda Susiripala

Add custom webpack dev middleware config (#1931)

parent 3306262b
......@@ -682,9 +682,15 @@ In order to extend our usage of `webpack`, you can define a function that extend
module.exports = {
webpack: (config, { dev }) => {
   // Perform customizations to config
   
   // Important: return the modified config
// Perform customizations to webpack config
// Important: return the modified config
return config
},
webpackDevMiddleware: (config) => {
// Perform customizations to webpack dev middleware config
// Important: return the modified config
return config
}
}
......
......@@ -5,6 +5,7 @@ const cache = new Map()
const defaultConfig = {
webpack: null,
webpackDevMiddleware: null,
poweredByHeader: true,
distDir: '.next',
assetPrefix: ''
......
......@@ -138,14 +138,21 @@ export default class HotReloader {
}
} : {}
this.webpackDevMiddleware = webpackDevMiddleware(compiler, {
let webpackDevMiddlewareConfig = {
publicPath: '/_next/webpack/',
noInfo: true,
quiet: true,
clientLogLevel: 'warning',
watchOptions: { ignored },
...windowsSettings
})
}
if (this.config.webpackDevMiddleware) {
console.log('> Using "webpackDevMiddleware" config function defined in next.config.js.')
webpackDevMiddlewareConfig = this.config.webpackDevMiddleware(webpackDevMiddlewareConfig)
}
this.webpackDevMiddleware = webpackDevMiddleware(compiler, webpackDevMiddlewareConfig)
this.webpackHotMiddleware = webpackHotMiddleware(compiler, {
path: '/_next/webpack-hmr',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment