mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 15:24:52 +09:00
Add --dev-plugin to compile plugins on the fly
Add hidden development option to run the webpack compiller for the given plugin(s) similar to the --dev option for the built-in web interface. This requires publicPath to be set in the webpack config and an updated version of webpack-dev-middleware to function correctly.
This commit is contained in:
1 parent
5ce3fb6cc6
commit
71804df3e0
7 files changed
+24
-4
No files matched your search
@@ -1862,6 +1862,7 @@ async function initialize() {
|
||||
})
|
||||
.command("run", "Run master server", yargs => {
|
||||
yargs.option("dev", { hidden: true, type: "boolean", nargs: 0 });
|
||||
yargs.option("dev-plugin", { hidden: true, type: "array" });
|
||||
})
|
||||
.demandCommand(1, "You need to specify a command to run")
|
||||
.strict()
|
||||
@@ -1954,15 +1955,29 @@ async function initialize() {
|
||||
|
||||
async function startServer(args) {
|
||||
// Start webpack development server if enabled
|
||||
if (args.dev) {
|
||||
if (args.dev || args.devPlugin) {
|
||||
logger.warn("Webpack development mode enabled");
|
||||
/* eslint-disable global-require */
|
||||
const webpack = require("webpack");
|
||||
const webpackDevMiddleware = require("webpack-dev-middleware");
|
||||
const webpackConfig = require("./webpack.config");
|
||||
const webpackConfigs = [];
|
||||
if (args.dev) {
|
||||
webpackConfigs.push(require("./webpack.config"));
|
||||
}
|
||||
if (args.devPlugin) {
|
||||
for (let name of args.devPlugin) {
|
||||
let info = pluginInfos.find(i => i.name === name);
|
||||
if (!info) {
|
||||
throw new libErrors.StartupError(`No plugin named ${name}`);
|
||||
}
|
||||
webpackConfigs.push(
|
||||
require(path.posix.join(info.requirePath, "webpack.config"))
|
||||
);
|
||||
}
|
||||
}
|
||||
/* eslint-enable global-require */
|
||||
|
||||
const compiler = webpack(webpackConfig({}));
|
||||
const compiler = webpack(webpackConfigs.map(config => config({})));
|
||||
devMiddleware = webpackDevMiddleware(compiler, {});
|
||||
app.use(devMiddleware);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
"react-dom": "^16.13.1",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"webpack-cli": "^3.3.12",
|
||||
"webpack-dev-middleware": "^3.7.2",
|
||||
"webpack-dev-middleware": "^4.1.0",
|
||||
"webpack-merge": "^5.2.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
||||
@@ -12,6 +12,7 @@ module.exports = (env = {}) => merge(common(env), {
|
||||
contentBase: "./dist/web",
|
||||
},
|
||||
output: {
|
||||
publicPath: "/",
|
||||
filename: "bundle.js",
|
||||
path: path.resolve(__dirname, "dist", "web"),
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@ module.exports = (env = {}) => merge(common(env), {
|
||||
context: __dirname,
|
||||
entry: "./web/index.jsx",
|
||||
output: {
|
||||
publicPath: "/plugin/global_chat/",
|
||||
filename: "bundle.js",
|
||||
path: path.resolve(__dirname, "dist", "web"),
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@ module.exports = (env = {}) => merge(common(env), {
|
||||
context: __dirname,
|
||||
entry: "./web/index.jsx",
|
||||
output: {
|
||||
publicPath: "/plugin/research_sync/",
|
||||
filename: "bundle.js",
|
||||
path: path.resolve(__dirname, "dist", "web"),
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@ module.exports = (env = {}) => merge(common(env), {
|
||||
context: __dirname,
|
||||
entry: "./web/index.jsx",
|
||||
output: {
|
||||
publicPath: "/plugin/statistics_exporter/",
|
||||
filename: "bundle.js",
|
||||
path: path.resolve(__dirname, "dist", "web"),
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@ module.exports = (env = {}) => merge(common(env), {
|
||||
context: __dirname,
|
||||
entry: "./web/index.jsx",
|
||||
output: {
|
||||
publicPath: "/plugin/subspace_storage/",
|
||||
filename: "bundle.js",
|
||||
path: path.resolve(__dirname, "dist", "web"),
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user