This guide covers building Adminator for production and deploying it to various hosting platforms.
Before deploying, you need to create an optimized production build.
npm run build
This creates an optimized, minified production build in the dist/ directory.
npm run build
Features:
npm run release:minified
Use case: Maximum optimization for production deployment
Features:
npm run release:unminified
Use case: Debugging production issues
Features:
# Clean and rebuild
npm run clean
npm run build
Removes the dist/ directory before building to ensure a fresh build.
After running the build command, the dist/ directory contains:
dist/
├── index.html # Main dashboard page
├── 404.html # Error pages
├── 500.html
├── signin.html # Authentication pages
├── signup.html
├── email.html # Application pages
├── compose.html
├── chat.html
├── calendar.html
├── charts.html
├── forms.html
├── buttons.html
├── ui.html
├── basic-table.html
├── datatable.html
├── google-maps.html
├── vector-maps.html
├── blank.html
└── assets/
├── bundle.[hash].js # Compiled JavaScript
├── styles.[hash].css # Compiled CSS
└── static/ # Images, fonts, etc.
├── fonts/
└── images/
Production builds include content hashes in filenames (e.g., bundle.a1b2c3d4.js) for:
The build process automatically applies:
JavaScript Optimization
CSS Optimization
Asset Optimization
Bundle Optimization
To analyze your bundle size:
# Install webpack-bundle-analyzer
npm install --save-dev webpack-bundle-analyzer
# Add to webpack config and rebuild
npm run build
Adminator can be deployed to various platforms:
1. Install Netlify CLI:
npm install -g netlify-cli
2. Build your project:
npm run build
3. Deploy:
netlify deploy --prod --dir=dist
Or use Netlify's drag-and-drop:
dist/ folder to deploynetlify.toml configuration:
[build]
command = "npm run build"
publish = "dist"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
1. Install Vercel CLI:
npm install -g vercel
2. Deploy:
vercel --prod
vercel.json configuration:
{
"buildCommand": "npm run build",
"outputDirectory": "dist",
"rewrites": [
{ "source": "/(.*)", "destination": "/" }
]
}
1. Install gh-pages:
npm install --save-dev gh-pages
2. Add deploy script to package.json:
{
"scripts": {
"deploy": "npm run build && gh-pages -d dist"
}
}
3. Deploy:
npm run deploy
4. Configure GitHub Pages:
gh-pages branch1. Connect your repository:
2. Configure build settings:
npm run builddist/3. Deploy:
1. Build your project:
npm run build
2. Install AWS CLI:
# Follow AWS CLI installation guide
aws configure
3. Create S3 bucket and upload:
# Create bucket
aws s3 mb s3://your-bucket-name
# Upload files
aws s3 sync dist/ s3://your-bucket-name --delete
# Enable static website hosting
aws s3 website s3://your-bucket-name --index-document index.html --error-document 404.html
4. Set up CloudFront (optional but recommended):
1. Build your project:
npm run build
2. Copy files to web root:
cp -r dist/* /var/www/html/
3. Configure .htaccess:
# .htaccess in dist/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
# Enable Gzip compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>
# Browser caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
</IfModule>
1. Build your project:
npm run build
2. Copy files to web root:
cp -r dist/* /usr/share/nginx/html/
3. Configure nginx.conf:
server {
listen 80;
server_name your-domain.com;
root /usr/share/nginx/html;
index index.html;
# Gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript;
gzip_min_length 1000;
# Browser caching
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# SPA fallback
location / {
try_files $uri $uri/ /index.html;
}
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
}
4. Restart Nginx:
sudo systemctl restart nginx
Create environment-specific configurations:
Development (.env.development):
NODE_ENV=development
API_URL=http://localhost:3000
DEBUG=true
Production (.env.production):
NODE_ENV=production
API_URL=https://api.yourdomain.com
DEBUG=false
In your JavaScript:
const apiUrl = process.env.API_URL || 'http://localhost:3000';
const isProduction = process.env.NODE_ENV === 'production';
Before deploying to production, verify:
After deployment, verify:
Site Accessibility
Functionality
Performance
Mobile Responsiveness
Console Errors
# Clear cache and rebuild
npm run clean
rm -rf node_modules package-lock.json
npm install
npm run build
dist/ folder.htaccess or nginx configMost hosting platforms enable Gzip/Brotli automatically. Verify:
# Check if Gzip is enabled
curl -H "Accept-Encoding: gzip" -I https://your-domain.com
Use a CDN for faster global delivery:
Set appropriate cache headers:
Create .github/workflows/deploy.yml:
name: Deploy to Production
on:
push:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Deploy to Netlify
uses: netlify/actions/cli@master
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
with:
args: deploy --prod --dir=dist
Congratulations on deploying Adminator! 🎉
Continue learning:
Need Help? Check the main README or open an issue.