Skip to content

Commit

Permalink
fix: respect client.needClientEntry and client.needHotEntry option (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jkzing authored Apr 13, 2021
1 parent 408530d commit a2b6db9
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/utils/DevServerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
42 changes: 42 additions & 0 deletions test/server/clientOptions-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
);
});
});
});

0 comments on commit a2b6db9

Please sign in to comment.