Skip to content

Commit

Permalink
Fix support for DynamicEntryPlugin (#1319)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikegreiling authored and SpaceK33z committed Feb 26, 2018
1 parent ab4eeb0 commit dd32166
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/util/addDevServerEntrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@ module.exports = function addDevServerEntrypoints(webpackOptions, devServerOptio

if (devServerOptions.hotOnly) { devClient.push('webpack/hot/only-dev-server'); } else if (devServerOptions.hot) { devClient.push('webpack/hot/dev-server'); }

[].concat(webpackOptions).forEach((wpOpt) => {
if (typeof wpOpt.entry === 'object' && !Array.isArray(wpOpt.entry)) {
Object.keys(wpOpt.entry).forEach((key) => {
wpOpt.entry[key] = devClient.concat(wpOpt.entry[key]);
const prependDevClient = (entry) => {
if (typeof entry === 'function') {
return () => Promise.resolve(entry()).then(prependDevClient);
}
if (typeof entry === 'object' && !Array.isArray(entry)) {
const entryClone = {};
Object.keys(entry).forEach((key) => {
entryClone[key] = devClient.concat(entry[key]);
});
} else if (typeof wpOpt.entry === 'function') {
wpOpt.entry = wpOpt.entry(devClient);
} else {
wpOpt.entry = devClient.concat(wpOpt.entry);
return entryClone;
}
return devClient.concat(entry);
};

[].concat(webpackOptions).forEach((wpOpt) => {
wpOpt.entry = prependDevClient(wpOpt.entry);
});
}
};

0 comments on commit dd32166

Please sign in to comment.