Skip to content

Commit 5a9e0ed

Browse files
feat: Add Netlify deployment guide and environment variables, update build scripts
1 parent f86544f commit 5a9e0ed

File tree

4 files changed

+197
-0
lines changed

4 files changed

+197
-0
lines changed

NETLIFY_DEPLOY_GUIDE.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Netlify Deployment Guide for AegisExpress Logistics
2+
3+
## Quick Deploy Options
4+
5+
### Option 1: Deploy from GitHub (Recommended)
6+
7+
1. **Connect Repository to Netlify:**
8+
- Go to [Netlify](https://app.netlify.com/)
9+
- Click "New site from Git"
10+
- Choose GitHub and authorize Netlify
11+
- Select your repository: `RabbitDaCoder/ExpressLogistics`
12+
13+
2. **Build Settings:**
14+
```
15+
Base directory: client
16+
Build command: npm run build
17+
Publish directory: client/dist
18+
```
19+
20+
3. **Environment Variables:**
21+
Copy from `NETLIFY_ENV_VARS.txt` and add in Netlify dashboard:
22+
- Site settings → Environment variables
23+
- Add each variable from the file
24+
25+
### Option 2: Deploy via Netlify CLI
26+
27+
1. **Install Netlify CLI:**
28+
```bash
29+
npm install -g netlify-cli
30+
```
31+
32+
2. **Login to Netlify:**
33+
```bash
34+
netlify login
35+
```
36+
37+
3. **Deploy from client directory:**
38+
```bash
39+
cd client
40+
netlify deploy --prod --dir=dist
41+
```
42+
43+
### Option 3: Drag & Drop Deploy
44+
45+
1. **Build locally:**
46+
```bash
47+
cd client
48+
npm install --legacy-peer-deps
49+
npm run build
50+
```
51+
52+
2. **Drag the `dist` folder to Netlify dashboard**
53+
54+
## Configuration Files Created
55+
56+
- `client/netlify.toml` - Netlify build configuration
57+
- `NETLIFY_ENV_VARS.txt` - Environment variables list
58+
59+
## Key Features Configured
60+
61+
**SPA Routing** - All routes redirect to index.html
62+
**Build Optimization** - CSS/JS minification and bundling
63+
**Security Headers** - XSS protection, frame options, etc.
64+
**Cache Control** - Optimized caching for static assets
65+
**Node.js 18** - Stable Node version for builds
66+
**Legacy Peer Deps** - Handles npm dependency conflicts
67+
68+
## Post-Deployment Steps
69+
70+
1. **Update API URL:**
71+
- Set `VITE_API_URL` to your Render API URL
72+
- Example: `https://your-api-name.onrender.com/api`
73+
74+
2. **Configure Custom Domain (Optional):**
75+
- Site settings → Domain management
76+
- Add your custom domain
77+
78+
3. **Set up Branch Deploys:**
79+
- Deploys → Deploy contexts
80+
- Configure preview deployments
81+
82+
## Build Troubleshooting
83+
84+
If build fails:
85+
86+
1. **Check build logs** in Netlify dashboard
87+
2. **Clear cache** in Site settings → Build & deploy
88+
3. **Try manual deploy** with Netlify CLI
89+
4. **Verify environment variables** are set correctly
90+
91+
## Performance Optimization
92+
93+
- Static assets cached for 1 year
94+
- HTML/CSS/JS minified automatically
95+
- Pretty URLs enabled
96+
- Gzip compression enabled by default
97+
98+
## Security Features
99+
100+
- XSS protection headers
101+
- Content type sniffing prevention
102+
- Frame clickjacking protection
103+
- Strict referrer policy
104+
105+
Your site will be available at: `https://your-site-name.netlify.app`

NETLIFY_ENV_VARS.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Netlify Environment Variables for AegisExpress Logistics
2+
3+
# API Configuration
4+
VITE_API_URL=https://your-api-domain.onrender.com/api
5+
6+
# Map Services
7+
VITE_MAPBOX_ACCESS_TOKEN=your_mapbox_token
8+
VITE_GOOGLE_MAPS_API_KEY=your_google_maps_key
9+
10+
# Cloudinary (for image uploads)
11+
VITE_CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
12+
VITE_CLOUDINARY_API_KEY=your_cloudinary_api_key
13+
14+
# Application Settings
15+
VITE_APP_NAME=AegisExpress Logistics
16+
VITE_APP_VERSION=1.0.0
17+
VITE_ENVIRONMENT=production
18+
19+
# Feature Flags
20+
VITE_ENABLE_TRACKING=true
21+
VITE_ENABLE_NOTIFICATIONS=true
22+
VITE_ENABLE_ANALYTICS=false
23+
24+
# Security
25+
VITE_ENABLE_HTTPS=true
26+
27+
# External Services (if needed)
28+
VITE_TELEGRAM_BOT_TOKEN=your_telegram_bot_token
29+
VITE_SUPPORT_EMAIL=support@aegisexpress.com
30+
31+
# Build Configuration
32+
NODE_VERSION=18
33+
NPM_FLAGS=--legacy-peer-deps
34+
CI=false

client/netlify.toml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[build]
2+
# Directory to change to before starting a build
3+
base = "client/"
4+
5+
# Directory that contains the deploy-ready HTML files and assets
6+
publish = "dist/"
7+
8+
# Default build command
9+
command = "npm run build"
10+
11+
[build.environment]
12+
# Node.js version
13+
NODE_VERSION = "18"
14+
15+
# npm settings
16+
NPM_FLAGS = "--legacy-peer-deps"
17+
18+
# Redirect rules for SPA routing
19+
[[redirects]]
20+
from = "/*"
21+
to = "/index.html"
22+
status = 200
23+
24+
# Custom headers for security and performance
25+
[[headers]]
26+
for = "/*"
27+
[headers.values]
28+
X-Frame-Options = "DENY"
29+
X-XSS-Protection = "1; mode=block"
30+
X-Content-Type-Options = "nosniff"
31+
Referrer-Policy = "strict-origin-when-cross-origin"
32+
33+
[[headers]]
34+
for = "/static/*"
35+
[headers.values]
36+
Cache-Control = "public, max-age=31536000, immutable"
37+
38+
# Error pages
39+
[[redirects]]
40+
from = "/404"
41+
to = "/index.html"
42+
status = 200
43+
44+
# Build optimization
45+
[build.processing]
46+
skip_processing = false
47+
48+
[build.processing.css]
49+
bundle = true
50+
minify = true
51+
52+
[build.processing.js]
53+
bundle = true
54+
minify = true
55+
56+
[build.processing.html]
57+
pretty_urls = true

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"build": "vite build",
99
"build:tsc": "tsc -b && vite build",
1010
"build:vercel": "vite build --mode production",
11+
"build:netlify": "npm ci --legacy-peer-deps && vite build --mode production",
1112
"lint": "eslint .",
1213
"preview": "vite preview"
1314
},

0 commit comments

Comments
 (0)