mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Drop build tool names from the controller and static_url docs
Controller.viteServer becomes devServer, matching the devMiddleware name it replaced. The static_url limitation is described as one of the web build rather than webpack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c92a44e65
commit
bf847b8c74
4 files changed
+13
-13
No files matched your search
@@ -103,7 +103,7 @@ Defaults to null meaning assume localhost.
|
|||||||
|
|
||||||
Used to override where static assets such as the web bundle is loaded from.
|
Used to override where static assets such as the web bundle is loaded from.
|
||||||
This can be used if you want to put the static assets on a separate cdn url like `https://cdn.example.com/static/` while keeping the API hosted directly by clusterio.
|
This can be used if you want to put the static assets on a separate cdn url like `https://cdn.example.com/static/` while keeping the API hosted directly by clusterio.
|
||||||
Due to a limitation on how the webpack assets are built the pathname component of the url have to be `/static/`, values with any other path are rejected.
|
Due to a limitation on how the web assets are built the pathname component of the url have to be `/static/`, values with any other path are rejected.
|
||||||
|
|
||||||
See also the `clusteriocontroller copy-static` command for how to obtain the static asset files that need to be hosted.
|
See also the `clusteriocontroller copy-static` command for how to obtain the static asset files that need to be hosted.
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export default class Controller {
|
|||||||
_registeredEvents = new Map<lib.EventClass<unknown>, lib.EventHandler<unknown>>();
|
_registeredEvents = new Map<lib.EventClass<unknown>, lib.EventHandler<unknown>>();
|
||||||
_snoopedEvents = new Map();
|
_snoopedEvents = new Map();
|
||||||
|
|
||||||
viteServer: import("vite").ViteDevServer | null = null;
|
devServer: import("vite").ViteDevServer | null = null;
|
||||||
|
|
||||||
startedAtMs = Date.now();
|
startedAtMs = Date.now();
|
||||||
autosaveInterval?: ReturnType<typeof setInterval>;
|
autosaveInterval?: ReturnType<typeof setInterval>;
|
||||||
@@ -416,8 +416,8 @@ export default class Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Controller.addAppRoutes(this.app, this.pluginInfos);
|
Controller.addAppRoutes(this.app, this.pluginInfos);
|
||||||
if (this.viteServer) {
|
if (this.devServer) {
|
||||||
this.app.use(this.viteServer.middlewares);
|
this.app.use(this.devServer.middlewares);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.dev) {
|
if (!args.dev) {
|
||||||
@@ -516,7 +516,7 @@ export default class Controller {
|
|||||||
this.app.locals.devPlugins = devPlugins;
|
this.app.locals.devPlugins = devPlugins;
|
||||||
|
|
||||||
const controllerDir = path.join(import.meta.dirname, "..", "..", "..");
|
const controllerDir = path.join(import.meta.dirname, "..", "..", "..");
|
||||||
this.viteServer = await vite.createServer({
|
this.devServer = await vite.createServer({
|
||||||
configFile: path.join(controllerDir, "vite.config.js"),
|
configFile: path.join(controllerDir, "vite.config.js"),
|
||||||
root: controllerDir,
|
root: controllerDir,
|
||||||
base: "/static/",
|
base: "/static/",
|
||||||
@@ -529,13 +529,13 @@ export default class Controller {
|
|||||||
});
|
});
|
||||||
if (args.dev) {
|
if (args.dev) {
|
||||||
this.app.locals.webBundle = {
|
this.app.locals.webBundle = {
|
||||||
main: this.viteServer.config.plugins.find(p => p.name === "clusterio:app")!.api.entry,
|
main: this.devServer.config.plugins.find(p => p.name === "clusterio:app")!.api.entry,
|
||||||
imports: Object.fromEntries(webUiVite.sharedModules.map(
|
imports: Object.fromEntries(webUiVite.sharedModules.map(
|
||||||
name => [name, webUiVite.devSharedUrl(name)]
|
name => [name, webUiVite.devSharedUrl(name)]
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
this.app.locals.viteServer = this.viteServer;
|
this.app.locals.devServer = this.devServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -586,8 +586,8 @@ export default class Controller {
|
|||||||
await this.clusterLogIndex.save();
|
await this.clusterLogIndex.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.viteServer) {
|
if (this.devServer) {
|
||||||
await this.viteServer.close();
|
await this.devServer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.hooks.shutdown.invoke();
|
await this.hooks.shutdown.invoke();
|
||||||
@@ -1388,8 +1388,8 @@ export default class Controller {
|
|||||||
.replace(/__IMPORT_MAP__/g, () => importMap)
|
.replace(/__IMPORT_MAP__/g, () => importMap)
|
||||||
.replace(/__MAIN_BUNDLE__/g, () => routes.stripStaticPrefix(main))
|
.replace(/__MAIN_BUNDLE__/g, () => routes.stripStaticPrefix(main))
|
||||||
;
|
;
|
||||||
if (res.app.locals.viteServer) {
|
if (res.app.locals.devServer) {
|
||||||
content = await res.app.locals.viteServer.transformIndexHtml(req.originalUrl, content);
|
content = await res.app.locals.devServer.transformIndexHtml(req.originalUrl, content);
|
||||||
}
|
}
|
||||||
res.type("text/html");
|
res.type("text/html");
|
||||||
res.send(content);
|
res.send(content);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ declare global {
|
|||||||
export interface Locals {
|
export interface Locals {
|
||||||
controller: Controller,
|
controller: Controller,
|
||||||
webBundle: { main: string, imports: Record<string, string> },
|
webBundle: { main: string, imports: Record<string, string> },
|
||||||
viteServer?: import("vite").ViteDevServer,
|
devServer?: import("vite").ViteDevServer,
|
||||||
staticRoot: string | null,
|
staticRoot: string | null,
|
||||||
devPlugins?: Map<string, string>,
|
devPlugins?: Map<string, string>,
|
||||||
streams: Map<string, ProxyStream>,
|
streams: Map<string, ProxyStream>,
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ export class ControllerConfig extends classes.Config<ControllerConfigFields> {
|
|||||||
optional: true,
|
optional: true,
|
||||||
validator: (value) => {
|
validator: (value) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
// This is unfortunately a limitiation of how the webpack build is set up right now.
|
// This is unfortunately a limitiation of how the web build is set up right now.
|
||||||
const pathname = new URL(value, "http://localhost/").pathname;
|
const pathname = new URL(value, "http://localhost/").pathname;
|
||||||
if (pathname !== "/static/") {
|
if (pathname !== "/static/") {
|
||||||
throw new Error(`Path component of static_url must be /static/ not ${pathname}.`);
|
throw new Error(`Path component of static_url must be /static/ not ${pathname}.`);
|
||||||
|
|||||||
Reference in new issue
Block a user