Skip to content

Commit f64fe61

Browse files
authored
Fixed an issue where server config wasn't applied properly (#141)
1 parent eaf600e commit f64fe61

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "remix-development-tools",
33
"description": "Remix development tools - a set of tools for developing/debugging Remix.run apps",
44
"author": "Alem Tuzlak",
5-
"version": "4.3.1",
5+
"version": "4.3.2",
66
"license": "MIT",
77
"keywords": [
88
"remix",

src/server/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ export interface DevToolsServerConfig {
1313
}
1414

1515
export const defineServerConfig = (config: DevToolsServerConfig) => config;
16-
export const getConfig = () => singleton("config", () => ({}) as DevToolsServerConfig);
16+
export const getConfig = () => typeof process !== "undefined" ? (process as any).rdt_config : singleton("config", () => ({}));

src/test-apps/remix-vite/vite.config.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ const config = defineRdtConfig({
99
panelLocation: "top",
1010
position: "top-right",
1111
requireUrlFlag: false
12-
},server: {},
12+
},server: {
13+
silent: true,
14+
},
1315
pluginDir: "./plugins",
1416
includeInProd: true,
15-
unstable_console: true
17+
1618
}, );
1719
export default defineConfig({
1820
plugins: [remixDevTools( config),remix({ future: {

src/vite/plugin.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export const remixDevTools: (args?:RemixViteConfig) => Plugin[] = (args) => {
3535
const improvedConsole = args?.improvedConsole ?? true;
3636
const shouldInject = (mode: string | undefined) => mode === "development" || include;
3737
let port = 5173;
38+
// Set the server config on the process object so that it can be accessed by the plugin
39+
if(typeof process !== "undefined"){
40+
(process as any).rdt_config = serverConfig;
41+
}
3842
return [
3943
{
4044
enforce: "pre",
@@ -45,7 +49,7 @@ export const remixDevTools: (args?:RemixViteConfig) => Plugin[] = (args) => {
4549
transform(code) {
4650
const RDT_PORT = "__REMIX_DEVELOPMENT_TOOL_SERVER_PORT__";
4751
if (code.includes(RDT_PORT)) {
48-
const modified = code.replaceAll(RDT_PORT, port.toString()).replaceAll(`singleton("config", () => ({}));`, `(${JSON.stringify(serverConfig)})`);
52+
const modified = code.replaceAll(RDT_PORT, port.toString());
4953
return modified;
5054
}
5155
},

0 commit comments

Comments
 (0)