webpack / webpack-dev-server

Serves a webpack app. Updates the browser on changes. Documentation https://webpack.js.org/configuration/dev-server/.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

addDevServerEntrypoints workaround

SFNGGL opened this issue · comments

Hello.
I got this snippet of what I assumed to be old code which I need to run:

const WebpackDevServer = require("webpack-dev-server");
const webpack = require("webpack");
const [mainConfig, rendererConfig] = require("./webpack.config.js")(null, { mode: "development" });
const childProcess = require("child_process");

const weblog = require("webpack-log");
const log = weblog({ name: "develop" });

async function main() {
process.on("unhandledRejection", (e) => {
log.error(Unhandled rejection , e.stack || e);
process.exit(1);
});
process.on("uncaughtException", (e) => {
log.error(Uncaught exception , e.stack || e);
process.exit(1);
});

const mainPromise = new Promise((resolve, reject) => {
webpack(mainConfig, (err, stats) => {
if (err) {
reject(err);
} else {
resolve(stats);
}
});
});

rendererConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
const devServerOptions = Object.assign({}, rendererConfig.devServer, {
stats: {
colors: true,
}
});
WebpackDevServer.addDevServerEntrypoints(rendererConfig, devServerOptions);
// this line right here^

const rendererCompiler = webpack(rendererConfig);
const server = new WebpackDevServer(rendererCompiler, devServerOptions);
const serverPromise = new Promise((resolve, reject) => {
let port = 9000;
try {
server.listen(port, "127.0.0.1", resolve(port));
} catch (e) {
reject(e);
}
})
...

The program then goes on, but it's not important right now. What I want to know is, since the addDevServerEntrypoints has been removed as a function, what workarounds could I implement to make this piece of code work. Note: it is not terribly important to me understanding it right now, I just want it to not throw a 'is not a function' error. (Sorry for the text file upload, it's a js file)
source repository: https://github.com/itchio/itch.git
develop.txt

You can use addAdditionalEntries https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L536C3-L536C23 right now instead addDevServerEntrypoints, feel free to feedback