I want to deploy my react app which was built using vite into AWS Amplify but the build is failing. Here’s how my package.json looks
{
"name": "app",
"author": "ashiqdey",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^7.2.6",
"react-router": "^6.2.1",
"react-router-dom": "^6.2.1",
},
"devDependencies": {
"@vitejs/plugin-react": "^2.1.0",
"prettier": "^2.5.1",
"vite": "^3.1.0"
}
}
What wrong I am doing?
Edit : Here’s my yml file, After getting vite command not found error I had added npm i vite -g, still no luck
3
Answers
Developing software: 49% time spent on cloud configuration, 49% on build scripts, 2% writing code. And this is with all the amazing new tools becoming available.
Your package file correct and just like mine (although my vite is older) so this answer may not help you.
The
amplify.yml
has a preBuild step that should be doing ayarn install
(ornpm install
), so vite and other packages will be downloaded.I have
amplify.yml
in the root of my project because I changedbaseDirectory: /
tobaseDirectory: /dist
.I have a
vite.config.ts
:My
index.html
has some extra for vite:EDIT
Here’s my
amplify.yml
file:Revert the amplify configuration back to its original form and try to check your package.json for these following settings.
Here is a video that has helped me with this issue using the amplify CLI, pre-built the backend definitions changed some directories and build commands for vite.
https://www.youtube.com/watch?v=Rvl4nua2IJw
I had many issues prior to this video so hopefully it helps for you.
Seems like amplify hasn’t fully embraced vite yet
Here is my amplify.yml afterwards: