Skip to content

Commit 8898717

Browse files
committed
fix: prevent devServer.before from being overridden by user config
1 parent b199c8f commit 8898717

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

examples/simple/nut.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ module.exports = {
4848
devServer: {
4949
proxy: {
5050
'/api': 'http://127.0.0.1:7000'
51-
}
51+
},
52+
before() {
53+
console.log( 'dev server before' )
54+
},
5255
},
5356
sidebar: null,
5457
landing: {

packages/cli/lib/commands/dev.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ async function dev( cliOptions = {} ) {
177177
}
178178

179179
if ( nutConfig.devServer ) {
180+
const userDevServerBefore = nutConfig.devServer.before
181+
const nutDevServerBefore = devServerOptions.before
182+
183+
if ( userDevServerBefore ) {
184+
devServerOptions.before = function ( ...args ) {
185+
nutDevServerBefore( ...args )
186+
return userDevServerBefore( ...args )
187+
}
188+
189+
delete nutConfig.devServer.before
190+
}
180191
devServerOptions = Object.assign( devServerOptions, nutConfig.devServer )
181192
}
182193

0 commit comments

Comments
 (0)