Currently, when deploying a new build in a React Vite application, there is an issue where the application tries to find the old index files instead of the newly deployed ones. However, this issue is resolved when the page is reloaded. #177
Closed
manishagupta016
started this conversation in
General
Replies: 1 comment
-
This is an issue related to frontend deployment in general and not Vite. The solution can be to keep the old deployment around for some time or force a reload when a chunk failed to load. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
package.json --> "build:config": "sh -ac '. ./environments/.env.${VITE_APP_ENV}; vite build --outDir dist/${VITE_APP_ENV}-new'"
vite.config.js
import { splitVendorChunkPlugin, defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import eslint from "vite-plugin-eslint";
import viteDefineEnvs from "./vite-define-envs-plugin";
const path = require("path");
// https://vitejs.dev/config/
export default defineConfig({
base : "/",
reactScriptsVersion: "react-scripts",
style : {
sass: {
loaderOptions: {
sassOptions: {
includePaths: ["node_modules", "src/assets"]
}
}
},
postcss: {}
},
resolve: {
alias: {
"@src" : path.resolve(__dirname, "src"),
"@panel" : path.resolve(__dirname, "src/views/panel"),
"@views" : path.resolve(__dirname, "src/views"),
"@components": path.resolve(__dirname, "src/@core/components"),
"@layouts" : path.resolve(__dirname, "src/layouts"),
"@Styles" : path.resolve(__dirname, "src/@core/scss"),
"@configs" : path.resolve(__dirname, "src/configs"),
"@utils" : path.resolve(__dirname, "src/utility/helpers/utils"),
"@hooks" : path.resolve(__dirname, "src/utility/hooks"),
"@services" : path.resolve(__dirname, "src/utility/services"),
"@helpers" : path.resolve(__dirname, "src/utility/helpers"),
"@Constants" : path.resolve(__dirname, "src/utility/constants"),
"@context" : path.resolve(__dirname, "src/utility/context")
}
},
plugins: [
react(),
eslint(),
new viteDefineEnvs(["REACT_APP_SC_ATTR", "SC_ATTR"], "process.env"),
splitVendorChunkPlugin()
],
exclude: ["/*.test.jsx", "/*.cy.js"],
build : {
publicDir: "/",
sourcemap: true // Enable sourcemaps for debugging
}
});
Beta Was this translation helpful? Give feedback.
All reactions