Skip to content

Commit a2b6db9

Browse files
authored
fix: respect client.needClientEntry and client.needHotEntry option (#3178)
1 parent 408530d commit a2b6db9

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

lib/utils/DevServerPlugin.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,21 @@ class DevServerPlugin {
158158

159159
/** @type {Entry} */
160160
const additionalEntries = checkInject(
161-
options.injectClient,
161+
options.client ? options.client.needClientEntry : null,
162162
compilerOptions,
163163
isWebTarget
164164
)
165165
? [clientEntry]
166166
: [];
167167

168-
if (hotEntry && checkInject(options.injectHot, compilerOptions, true)) {
168+
if (
169+
hotEntry &&
170+
checkInject(
171+
options.client ? options.client.needHotEntry : null,
172+
compilerOptions,
173+
true
174+
)
175+
) {
169176
additionalEntries.push(hotEntry);
170177
}
171178

test/server/clientOptions-option.test.js

+42
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,46 @@ describe('client option', () => {
6969
req.get(path).expect(200, done);
7070
});
7171
});
72+
73+
describe('configure client entry', () => {
74+
it('disables client entry', (done) => {
75+
server = testServer.start(
76+
config,
77+
{
78+
client: {
79+
needClientEntry: false,
80+
},
81+
port,
82+
},
83+
() => {
84+
request(server.app)
85+
.get('/main.js')
86+
.then((res) => {
87+
expect(res.text).not.toMatch(/client\/index\.js/);
88+
})
89+
.then(done, done);
90+
}
91+
);
92+
});
93+
94+
it('disables hot entry', (done) => {
95+
server = testServer.start(
96+
config,
97+
{
98+
client: {
99+
needHotEntry: false,
100+
},
101+
port,
102+
},
103+
() => {
104+
request(server.app)
105+
.get('/main.js')
106+
.then((res) => {
107+
expect(res.text).not.toMatch(/webpack\/hot\/dev-server\.js/);
108+
})
109+
.then(done, done);
110+
}
111+
);
112+
});
113+
});
72114
});

0 commit comments

Comments
 (0)