Fix --dev-plugin breaking after bd53339

The automatic determination of the public path for plugins works
correctly when they are build for production and loaded from their
respective paths.  But when the dev middelware compiles it, it doesn't
know the correct path to host it at withouth the publicPath being set.

Fix by setting publicPath explicitly when compiling with the dev
middleware.
This commit is contained in:
Hornwitser committed 2021-03-20 03:35:05 +01:00
1 parent 3d26371fa9
commit 48786f1e59
1 file changed
+5 -5
+5 -5
View File
@@ -2012,7 +2012,7 @@ async function startServer(args) {
const webpackDevMiddleware = require("webpack-dev-middleware");
const webpackConfigs = [];
if (args.dev) {
webpackConfigs.push(require("./webpack.config"));
webpackConfigs.push(require("./webpack.config")({}));
}
if (args.devPlugin) {
for (let name of args.devPlugin) {
@@ -2020,14 +2020,14 @@ async function startServer(args) {
if (!info) {
throw new libErrors.StartupError(`No plugin named ${name}`);
}
webpackConfigs.push(
require(path.posix.join(info.requirePath, "webpack.config"))
);
let config = require(path.posix.join(info.requirePath, "webpack.config"))({});
config.output.publicPath = `/plugins/${name}/`;
webpackConfigs.push(config);
}
}
/* eslint-enable global-require */
const compiler = webpack(webpackConfigs.map(config => config({})));
const compiler = webpack(webpackConfigs);
devMiddleware = webpackDevMiddleware(compiler, {});
app.use(devMiddleware);
}