Skip to content

bebeal/vite-amplify

 
 

Repository files navigation

vite-amplify (no-ssr)

Vite Template with Express APIs + Amplify Hosting.

Note: This branch has no SSR. It retains the express api server but removes the actual server side rendering -> client side hydration.

vite-amplify-no-ssr.com

~4 mins from fork-to-finish for a successful deployment

vite-amplify-landing

Features

Other Libraries

Development

Using yarn

yarn install      // install dependencies
Image
yarn dev          // run the development server
Image
yarn build        // build both client side and server side build
Image

Additional Commands

yarn clean        // clean everything thats generated in the build/dev process
yarn build:client // build the client side to dist/client
yarn build:server // build the server side to dist/server
yarn lint         // run eslint
yarn format       // run prettier

Amplify Hosting

To deploy to Amplify Hosting

  1. Create repository from template
  2. Deploy to AWS

Note: set env variable YARN_ENABLE_IMMUTABLE_INSTALLS=0 in the Amplify console

Screenshot 2025-04-04 at 8 02 19 PM

Build

The build outputs to dist folder. The build is split into two parts, the client side and the server side.

dist
├── client
│   ├── assets
│   │   ├── index-CKLaldzO.css       30.02 kB │ gzip:     6.63 kB
│   │   └── index-_V89bRVz.js       325.27 kB │ gzip:   107.74 kB
│   ├── favicon.ico                  14.73 kB │ gzip:     4.46 kB
│   ├── index.html                     .54 kB │ gzip:      .34 kB
│   └── robots.txt                     .06 kB │ gzip:      .08 kB
└── server
    ├── api
    │   ├── api.d.ts                   .21 kB │ gzip:      .16 kB
    │   └── api.js                    1.01 kB │ gzip:      .47 kB
    ├── server.d.ts                    .25 kB │ gzip:      .18 kB
    ├── server.js                     3.27 kB │ gzip:     1.38 kB
    ├── tsconfig.node.tsbuildinfo    46.99 kB │ gzip:    14.90 kB
    ├── vite.config.d.ts               .08 kB │ gzip:      .10 kB
    └── vite.config.js                 .72 kB │ gzip:      .36 kB

5 directories, 12 files

Amplify Build

  • amplify.yml is the build spec for Amplify Hosting (AWS Docs)

  • deploy-minifest.json is the deployment spec and is what deploys the express api server (AWS Docs)

  • postbuild.sh will take the build from dist and copy it over to the amplify build folder (.amplify-hosting) which results in (AWS Docs):

.amplify-hosting
├── compute
│   └── default
│       ├── client
│       │   ├── assets
│       │   │   ├── index-CKLaldzO.css          30.02 kB │ gzip:     6.63 kB
│       │   │   └── index-_V89bRVz.js          325.27 kB │ gzip:   107.74 kB
│       │   ├── favicon.ico                     14.73 kB │ gzip:     4.46 kB
│       │   ├── index.html                        .54 kB │ gzip:      .34 kB
│       │   └── robots.txt                        .06 kB │ gzip:      .08 kB
│       ├── package.json                         2.02 kB │ gzip:      .82 kB
│       └── server
│           ├── api
│           │   ├── api.d.ts                      .21 kB │ gzip:      .16 kB
│           │   └── api.js                       1.01 kB │ gzip:      .47 kB
│           ├── server.d.ts                       .25 kB │ gzip:      .18 kB
│           ├── server.js                        3.27 kB │ gzip:     1.38 kB
│           ├── tsconfig.node.tsbuildinfo       46.99 kB │ gzip:    14.90 kB
│           ├── vite.config.d.ts                  .08 kB │ gzip:      .10 kB
│           └── vite.config.js                    .72 kB │ gzip:      .36 kB
├── deploy-manifest.json                          .83 kB │ gzip:      .33 kB
└── static
    ├── favicon.ico                             14.73 kB │ gzip:     4.46 kB
    └── robots.txt                                .06 kB │ gzip:      .08 kB

8 directories, 16 files

Lighthouse

100_91_96_100

¯\(ツ)/¯ 🧂 lighthouse_summary_100_91_96_100_july282024.pdf