First commit
This commit is contained in:
40
hGameTest/node_modules/webpack-dev-server/lib/util/addDevServerEntrypoints.js
generated
vendored
Normal file
40
hGameTest/node_modules/webpack-dev-server/lib/util/addDevServerEntrypoints.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
/* eslint no-param-reassign: 'off' */
|
||||
|
||||
const createDomain = require('./createDomain');
|
||||
|
||||
module.exports = function addDevServerEntrypoints(webpackOptions, devServerOptions, listeningApp) {
|
||||
if (devServerOptions.inline !== false) {
|
||||
// we're stubbing the app in this method as it's static and doesn't require
|
||||
// a listeningApp to be supplied. createDomain requires an app with the
|
||||
// address() signature.
|
||||
const app = listeningApp || {
|
||||
address() {
|
||||
return { port: devServerOptions.port };
|
||||
}
|
||||
};
|
||||
const domain = createDomain(devServerOptions, app);
|
||||
const devClient = [`${require.resolve('../../client/')}?${domain}`];
|
||||
|
||||
if (devServerOptions.hotOnly) { devClient.push('webpack/hot/only-dev-server'); } else if (devServerOptions.hot) { devClient.push('webpack/hot/dev-server'); }
|
||||
|
||||
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]);
|
||||
});
|
||||
return entryClone;
|
||||
}
|
||||
return devClient.concat(entry);
|
||||
};
|
||||
|
||||
[].concat(webpackOptions).forEach((wpOpt) => {
|
||||
wpOpt.entry = prependDevClient(wpOpt.entry);
|
||||
});
|
||||
}
|
||||
};
|
||||
23
hGameTest/node_modules/webpack-dev-server/lib/util/createDomain.js
generated
vendored
Normal file
23
hGameTest/node_modules/webpack-dev-server/lib/util/createDomain.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
const url = require('url');
|
||||
const internalIp = require('internal-ip');
|
||||
|
||||
|
||||
module.exports = function createDomain(options, listeningApp) {
|
||||
const protocol = options.https ? 'https' : 'http';
|
||||
const appPort = listeningApp ? listeningApp.address().port : 0;
|
||||
const port = options.socket ? 0 : appPort;
|
||||
const hostname = options.useLocalIp ? internalIp.v4() : options.host;
|
||||
|
||||
// use explicitly defined public url (prefix with protocol if not explicitly given)
|
||||
if (options.public) {
|
||||
return /^[a-zA-Z]+:\/\//.test(options.public) ? `${options.public}` : `${protocol}://${options.public}`;
|
||||
}
|
||||
// the formatted domain (url without path) of the webpack server
|
||||
return url.format({
|
||||
protocol,
|
||||
hostname,
|
||||
port
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user