Skip to content

Commit

Permalink
fix(remix-dev/vite): remove Vite v4 back compat (#8581)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish committed Jan 23, 2024
1 parent 6debfd5 commit a8fb7d8
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions packages/remix-dev/vite/plugin.ts
Expand Up @@ -405,11 +405,6 @@ const getServerBundleBuildConfig = (
return viteUserConfig.__remixServerBundleBuildConfig as ServerBundleBuildConfig;
};

const getViteMajorVersion = (): number => {
let vitePkg = require("vite/package.json");
return parseInt(vitePkg.version.split(".")[0]!);
};

export let getServerBuildDirectory = (remixConfig: ResolvedVitePluginConfig) =>
path.join(
remixConfig.buildDirectory,
Expand All @@ -428,8 +423,6 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
let viteUserConfig: Vite.UserConfig;
let viteConfig: Vite.ResolvedConfig | undefined;

let isViteV4 = getViteMajorVersion() === 4;

let cssModulesManifest: Record<string, string> = {};
let ssrBuildContext:
| { isSsrBuild: false }
Expand Down Expand Up @@ -586,11 +579,8 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
};

let loadViteManifest = async (directory: string) => {
let manifestPath = isViteV4
? "manifest.json"
: path.join(".vite", "manifest.json");
let manifestContents = await fse.readFile(
path.resolve(directory, manifestPath),
path.resolve(directory, ".vite", "manifest.json"),
"utf-8"
);
return JSON.parse(manifestContents) as Vite.Manifest;
Expand Down Expand Up @@ -731,12 +721,6 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
)
);

let isSsrBuild =
"ssrBuild" in viteConfigEnv &&
typeof viteConfigEnv.ssrBuild === "boolean"
? viteConfigEnv.ssrBuild // Vite v4 back compat
: viteConfigEnv.isSsrBuild;

return {
__remixPluginResolvedConfig: remixConfig,
appType: "custom",
Expand Down Expand Up @@ -784,7 +768,7 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
base: remixConfig.publicPath,
build: {
...viteUserConfig.build,
...(!isSsrBuild
...(!viteConfigEnv.isSsrBuild
? {
manifest: true,
outDir: getClientBuildDirectory(remixConfig),
Expand Down Expand Up @@ -862,9 +846,7 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
{
command: viteConfig.command,
mode: viteConfig.mode,
...(isViteV4
? { ssrBuild: ssrBuildContext.isSsrBuild }
: { isSsrBuild: ssrBuildContext.isSsrBuild }),
isSsrBuild: ssrBuildContext.isSsrBuild,
},
viteConfig.configFile
);
Expand Down

0 comments on commit a8fb7d8

Please sign in to comment.