Skip to content

Commit

Permalink
Fixed an issue where server config wasn't applied properly (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlemTuzlak committed Aug 24, 2024
1 parent eaf600e commit f64fe61
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "remix-development-tools",
"description": "Remix development tools - a set of tools for developing/debugging Remix.run apps",
"author": "Alem Tuzlak",
"version": "4.3.1",
"version": "4.3.2",
"license": "MIT",
"keywords": [
"remix",
Expand Down
2 changes: 1 addition & 1 deletion src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export interface DevToolsServerConfig {
}

export const defineServerConfig = (config: DevToolsServerConfig) => config;
export const getConfig = () => singleton("config", () => ({}) as DevToolsServerConfig);
export const getConfig = () => typeof process !== "undefined" ? (process as any).rdt_config : singleton("config", () => ({}));
6 changes: 4 additions & 2 deletions src/test-apps/remix-vite/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ const config = defineRdtConfig({
panelLocation: "top",
position: "top-right",
requireUrlFlag: false
},server: {},
},server: {
silent: true,
},
pluginDir: "./plugins",
includeInProd: true,
unstable_console: true

}, );
export default defineConfig({
plugins: [remixDevTools( config),remix({ future: {
Expand Down
6 changes: 5 additions & 1 deletion src/vite/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export const remixDevTools: (args?:RemixViteConfig) => Plugin[] = (args) => {
const improvedConsole = args?.improvedConsole ?? true;
const shouldInject = (mode: string | undefined) => mode === "development" || include;
let port = 5173;
// Set the server config on the process object so that it can be accessed by the plugin
if(typeof process !== "undefined"){
(process as any).rdt_config = serverConfig;
}
return [
{
enforce: "pre",
Expand All @@ -45,7 +49,7 @@ export const remixDevTools: (args?:RemixViteConfig) => Plugin[] = (args) => {
transform(code) {
const RDT_PORT = "__REMIX_DEVELOPMENT_TOOL_SERVER_PORT__";
if (code.includes(RDT_PORT)) {
const modified = code.replaceAll(RDT_PORT, port.toString()).replaceAll(`singleton("config", () => ({}));`, `(${JSON.stringify(serverConfig)})`);
const modified = code.replaceAll(RDT_PORT, port.toString());
return modified;
}
},
Expand Down

0 comments on commit f64fe61

Please sign in to comment.