mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-25 00:23:12 +09:00
Merge pull request #1174 from clusterio/fix/dev-plugin-shared-modules
Serve the web interface from source with --dev-plugin
This commit is contained in:
2 files changed
+10
-9
No files matched your search
@@ -125,6 +125,7 @@ For web development on the controller there are also the following flags:
|
|||||||
`--dev` - Serve the `web_ui` package from source through Vite's development server with hot module replacement.
|
`--dev` - Serve the `web_ui` package from source through Vite's development server with hot module replacement.
|
||||||
|
|
||||||
`--dev-plugin [name]` - Serve the web module for the given plugin from source the same way.
|
`--dev-plugin [name]` - Serve the web module for the given plugin from source the same way.
|
||||||
|
This also serves the `web_ui` package from source, as the plugin has to share its modules with it.
|
||||||
|
|
||||||
These options can be combined and multiple plugins can be actived for dev mode.
|
These options can be combined and multiple plugins can be actived for dev mode.
|
||||||
Keep in mind if you're working on external plugins the `--dev-plugin` option is likely to only work if the plugin is placed inside the `external_plugins` directory and its dependencies are installed with pnpm as part of the clusterio repository workspace.
|
Keep in mind if you're working on external plugins the `--dev-plugin` option is likely to only work if the plugin is placed inside the `external_plugins` directory and its dependencies are installed with pnpm as part of the clusterio repository workspace.
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ export default class Controller {
|
|||||||
this.app.use(this.devServer.middlewares);
|
this.app.use(this.devServer.middlewares);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.dev) {
|
if (!this.devServer) {
|
||||||
let manifestPath = path.join(import.meta.dirname, "..", "..", "web", "manifest.json");
|
let manifestPath = path.join(import.meta.dirname, "..", "..", "web", "manifest.json");
|
||||||
|
|
||||||
let manifest = await Controller.loadJsonObject(manifestPath);
|
let manifest = await Controller.loadJsonObject(manifestPath);
|
||||||
@@ -534,14 +534,14 @@ export default class Controller {
|
|||||||
},
|
},
|
||||||
plugins: [webUiVite.clusterioDevPlugins(pluginDirs)],
|
plugins: [webUiVite.clusterioDevPlugins(pluginDirs)],
|
||||||
});
|
});
|
||||||
if (args.dev) {
|
// Plugins served from source import the shared modules from the development server, the web
|
||||||
this.app.locals.webBundle = {
|
// interface has to use the same copies, so it is served from source as well with --dev-plugin.
|
||||||
main: this.devServer.config.plugins.find(p => p.name === "clusterio:app")!.api.entry,
|
this.app.locals.webBundle = {
|
||||||
imports: Object.fromEntries(webUiVite.sharedModules.map(
|
main: this.devServer.config.plugins.find(p => p.name === "clusterio:app")!.api.entry,
|
||||||
name => [name, webUiVite.devSharedUrl(name)]
|
imports: Object.fromEntries(webUiVite.sharedModules.map(
|
||||||
)),
|
name => [name, webUiVite.devSharedUrl(name)]
|
||||||
};
|
)),
|
||||||
}
|
};
|
||||||
this.app.locals.devServer = this.devServer;
|
this.app.locals.devServer = this.devServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user