-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed as not planned
Closed as not planned
Copy link
Description
Reproduction
vite.config.js
import { vitePlugin as remix } from "@remix-run/dev";
import { installGlobals } from "@remix-run/node";
import { defineConfig } from "vite";
installGlobals();
export default defineConfig({
plugins: [remix()],
});
Step 1
.env
TEST_VARIABLE="test"
_index.js
export default function Index() {
return <p>hello</p>;
}
export function loader() {
console.log(process.env.TEST_VARIABLE);
}
Prints "test" on the server console.
Step 2
Change the variable value:
.env
TEST_VARIABLE="another test"
Vite will print the following in the console:
[vite] .env changed, restarting server...
[vite] server restarted.
The server restarts, but the loader still prints "test" rather than "another test".
System Info
System:
OS: Windows 11 10.0.22631
CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
Memory: 22.05 GB / 31.92 GB
Binaries:
Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.21 - ~\AppData\Roaming\npm\yarn.CMD
npm: 10.2.5 - C:\Program Files\nodejs\npm.CMD
pnpm: 8.11.0 - ~\AppData\Roaming\npm\pnpm.CMD
Browsers:
Edge: Chromium (123.0.2420.97)
Internet Explorer: 11.0.22621.3527
npmPackages:
@remix-run/dev: ^2.9.2 => 2.9.2
@remix-run/node: ^2.9.2 => 2.9.2
@remix-run/react: ^2.9.2 => 2.9.2
@remix-run/serve: ^2.9.2 => 2.9.2
vite: ^5.1.0 => 5.2.11
Used Package Manager
npm
Expected Behavior
After changing the environment variable, the server should restart and the new value should be applied.
Actual Behavior
The server restarts, but the value doesn't actually change (only after the server is manually stopped/started).
carry0987, Marcdj-02, ynb-vtl and lasseklovstad