diff --git a/lib/utils/DevServerPlugin.js b/lib/utils/DevServerPlugin.js index cd9118028c..3da13aaab0 100644 --- a/lib/utils/DevServerPlugin.js +++ b/lib/utils/DevServerPlugin.js @@ -158,14 +158,21 @@ class DevServerPlugin { /** @type {Entry} */ const additionalEntries = checkInject( - options.injectClient, + options.client ? options.client.needClientEntry : null, compilerOptions, isWebTarget ) ? [clientEntry] : []; - if (hotEntry && checkInject(options.injectHot, compilerOptions, true)) { + if ( + hotEntry && + checkInject( + options.client ? options.client.needHotEntry : null, + compilerOptions, + true + ) + ) { additionalEntries.push(hotEntry); } diff --git a/test/server/clientOptions-option.test.js b/test/server/clientOptions-option.test.js index 8debb1ce3b..83b43f2808 100644 --- a/test/server/clientOptions-option.test.js +++ b/test/server/clientOptions-option.test.js @@ -69,4 +69,46 @@ describe('client option', () => { req.get(path).expect(200, done); }); }); + + describe('configure client entry', () => { + it('disables client entry', (done) => { + server = testServer.start( + config, + { + client: { + needClientEntry: false, + }, + port, + }, + () => { + request(server.app) + .get('/main.js') + .then((res) => { + expect(res.text).not.toMatch(/client\/index\.js/); + }) + .then(done, done); + } + ); + }); + + it('disables hot entry', (done) => { + server = testServer.start( + config, + { + client: { + needHotEntry: false, + }, + port, + }, + () => { + request(server.app) + .get('/main.js') + .then((res) => { + expect(res.text).not.toMatch(/webpack\/hot\/dev-server\.js/); + }) + .then(done, done); + } + ); + }); + }); });