-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace NextJS with Vite
#1431
Replace NextJS with Vite
#1431
Conversation
…o lesgoo/switchtovite
- remove next config and types - Add vite and react-router-dom - Add vite config - Create index.html (update with metadata from next/head) - Create main.tsx (entry point) - Add CSS imports, providers to entry point - Create router.tsx to handle page router - Add DAOController and Layout element to Router - Add Pages to Router (A few index -> default component name file changes) - Replace next's Script with custom hook - Replace next Link Component with React Router Link - Replace process.env -> import.meta with update ENV names - Replace next/image component with Chakra Image component - Replace next/router push instances with `useNavigate` - Replace package.json next scripts with vite runner
✅ Deploy Preview for test-vite-fractalframework ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test everything workflow you can think of. Should only notice the app being smoother everywhere. report any weirdness and I'll look into it.
src/router.tsx
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was surprisingly pretty straight forward to create. Just takes the 'index' of each page folder formally the page.tsx
and place as the element.
.env
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to update local env files as well from NEXT_PUBLIC_
-> VITE_APP_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot test this since Goerli is no longer supported. Should we just remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah just remove this script - it was purely for user testing on Goerli, we don't need it anymore
vite.config.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far in my testing, all I've had to update here is the plugin for nodepolyfils. This was fixing a 'process is not defined' and 'global is not defined' errors when setting up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing job!
Wasn't expecting it would be relatively simple. Have bunch of comments for changes, but other than that - looks good! Gonna test it in a moment
@@ -6,13 +6,13 @@ import * as Sentry from '@sentry/react'; | |||
export function initErrorLogging() { | |||
if ( | |||
process.env.NODE_ENV === 'development' || | |||
process.env.NEXT_PUBLIC_SENTRY_DSN_URL === undefined | |||
import.meta.env.VITE_APP_SENTRY_DSN_URL === undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is not related to the topic of this PR, but we need to make sure it is not an empty string as well. We have VITE_APP_SENTRY_DSN_URL=""
in .env
and I think it is good idea to keep that on env file, but then we need to make sure it is not an empty string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah just remove this script - it was purely for user testing on Goerli, we don't need it anymore
const { push } = useRouter(); | ||
const searchParams = useSearchParams(); | ||
const navigate = useNavigate(); | ||
let [searchParams] = useSearchParams(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be const
I believe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs shows let? https://reactrouter.com/en/main/hooks/use-search-params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but, please make it a const
cause we're not changing it.
- replace NextLink -> RouterLink - remove ETHLizardsScript
@mudrila All your comments have been address, sir. (+some) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the new VITE_APP_NAME
env var in all the places in the codebase that we were originally using the APP_NAME
constant defined in src/constants/common.ts
? And then, remove that constant from common.ts
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deployed site doesn't load if you refresh the page on any non-root URL.
This is known and expected.
There's a simple fix for Netlify hosting, which allows us to keep the BrowserRouter
and not need to switch to a HashRouter
.
See this commit from the fractal-interface-2
repo: decentdao/fractal-interface-2@6bc7702
/> | ||
<meta | ||
name="description" | ||
content="Are you outgrowing your Multisig? Fractal extends Safe treasuries into on-chain hierarchies of permissions, token flows, and governance." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blah, I think that either this should be in an env var, or we just hardcode "Fractal" back into the places where we are using VITE_APP_NAME.
Why have some of this metadata hardcoded and others controlled by environment?
But whatever, it's fine for now.
export default defineConfig({ | ||
plugins: [nodePolyfills(), react()], | ||
server: { | ||
port: 3000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Da-Colon just wondering, does it actually matter to force this to run on 3000? THIS AIN'T A NEXT APP ANY LONGER BOYYEEEEEE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol fair. more for me and my history autocomplete :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really have a preference. btw we can definately just go with the defaults of vite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference is that we just go with the vite default
src/metadata/lizzardsDAO/index.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this whole file and associated other lizard-specific files get removed too? I'm not sure where we stand on that....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mudrila @tomstuart123 ^^^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The export from this file isn't being consumed anywhere, so from a codebase perspective, it's safe to delete this file. I wonder if we should hold on to it for future use though...
const { push } = useRouter(); | ||
const searchParams = useSearchParams(); | ||
const navigate = useNavigate(); | ||
let [searchParams] = useSearchParams(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but, please make it a const
cause we're not changing it.
@Da-Colon can you explain the difference between This commit has me scratching my head... why change the |
Chakra-UI's Link basically is a stylable Switching to As far as the various uses. Looking through how I've updated it. React-Router's Chakra-UI's In the case of needing to be styled and internal. Chakra's |
@Da-Colon this makes a lot of sense, thank you |
So I think this is good to go Successful Test cases for both multisig + token dao
these were for subdao, token send and create a proposal flow just a note - I did have old issues reccur with subdao activity but david pointed me to a seperate PR for that - https://discord.com/channels/839548879216181309/1174434485043998860/1219698481091055699 final note - I did get this error that I had never seen before. Hard to replicate this was the only new thing and happened pretty rarely. I think we're good to go on this |
New Error you are experiencing is this? https://github.com/orgs/decentdao/projects/32/views/3?pane=issue&itemId=56621736 |
useNavigate
Testing
Note: Deployed preview will not work.
I deployed this branch manually on netlify. Here is the link: https://test-vite-fractalframework.netlify.app/