Skip to content

Commit

Permalink
fix(vite): Remove Vite production use warnings (#8266)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish committed Dec 12, 2023
1 parent 7562e4d commit 1d80110
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions packages/remix-dev/vite/plugin.ts
Expand Up @@ -276,16 +276,6 @@ const getRouteModuleExports = async (
return exportNames;
};

const showUnstableWarning = () => {
console.warn(
colors.yellow(
colors.bold(
"\n ⚠️ Remix support for Vite is unstable and\n not yet recommended for production\n"
)
)
);
};

const getViteMajorVersion = (): number => {
let vitePkg = require("vite/package.json");
return parseInt(vitePkg.version.split(".")[0]!);
Expand Down Expand Up @@ -723,14 +713,6 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
buildStart() {
invariant(viteConfig);

if (
viteCommand === "build" &&
// Only show warning on initial client build
!viteConfig.build.ssr
) {
showUnstableWarning();
}

if (
viteCommand === "build" &&
viteConfig.mode === "production" &&
Expand All @@ -739,26 +721,24 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
) {
viteConfig.logger.warn(
colors.yellow(
colors.bold(" ⚠️ Source maps are enabled in production\n") +
"\n" +
colors.bold(" ⚠️ Source maps are enabled in production\n") +
[
"This makes your server code publicly",
"visible in the browser. This is highly",
"discouraged! If you insist, ensure that",
"you are using environment variables for",
"secrets and not hard-coding them in",
"your source code.\n",
"your source code.",
]
.map((line) => " " + line)
.join("\n")
.join("\n") +
"\n"
)
);
}
},
configureServer(viteDevServer) {
viteDevServer.httpServer?.on("listening", () => {
setTimeout(showUnstableWarning, 50);
});

setDevServerHooks({
// Give the request handler access to the critical CSS in dev to avoid a
// flash of unstyled content since Vite injects CSS file contents via JS
Expand Down

0 comments on commit 1d80110

Please sign in to comment.