Skip to content

Commit

Permalink
add router fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Victoria-Fedkova committed Sep 25, 2023
1 parent 093d9ff commit 570bb2d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import { HashRouter } from 'react-router-dom';
import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';

Expand All @@ -13,10 +13,14 @@ ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<HashRouter>
<BrowserRouter
basename={
import.meta.env.DEV ? '/' : '/react-vite-project-template-js/'
}
>
<GlobalStyle />
<App />
</HashRouter>
</BrowserRouter>
</PersistGate>
</Provider>
</React.StrictMode>
Expand Down
13 changes: 10 additions & 3 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

export default defineConfig({
base: "/wheels4rent/",
export default defineConfig(({ command }) => {
const config = {
plugins: [react()],
base: "/",
};

plugins: [react()],
if (command !== "serve") {
config.base = "/wheels4rent/";
}

return config;
});

0 comments on commit 570bb2d

Please sign in to comment.