Skip to main content
StockPro is a static web application that can be deployed to any static hosting platform. This guide covers deployment to Firebase Hosting, Netlify, and Vercel.

Pre-Deployment Checklist

Before deploying to production, ensure you have:
1

Configure Firebase

Complete the Firebase Setup with production credentials.
2

Set Security Rules

Configure Firestore Security Rules to protect your data.
3

Test Locally

Test all features locally with your production Firebase project.
4

Create Admin User

Create at least one admin user in Firebase Authentication console.
Never deploy without security rules! Your database will be vulnerable to unauthorized access.

Deployment Options

Firebase Hosting provides seamless integration with Firebase services and automatic SSL certificates.
1

Install Firebase CLI

Install the Firebase command-line tools:
npm install -g firebase-tools
2

Login to Firebase

Authenticate with your Google account:
firebase login
3

Initialize Firebase Hosting

Navigate to your StockPro source directory and initialize hosting:
cd ~/workspace/source
firebase init hosting
When prompted:
  • Select project: Choose your Firebase project
  • Public directory: Enter public
  • Configure as SPA: No
  • Set up automatic builds: No
  • Overwrite files: No
4

Deploy to Firebase

Deploy your application:
firebase deploy --only hosting
Your app will be deployed to: https://your-project.web.app

Custom Domain Setup (Firebase)

1

Navigate to Hosting Settings

Go to Firebase Console → Hosting → Add custom domain
2

Enter Your Domain

Enter your domain name (e.g., stockpro.yourdomain.com)
3

Verify Ownership

Add the provided TXT record to your DNS settings
4

Configure DNS

Add the A records provided by Firebase to your DNS:
A    @    151.101.1.195
A    @    151.101.65.195
Or for subdomains, use CNAME:
CNAME    stockpro    your-project.web.app
SSL certificates are automatically provisioned and renewed by Firebase. This may take up to 24 hours for initial setup.

Option 2: Netlify

Netlify offers simple drag-and-drop deployment with automatic SSL and global CDN.
1

Create Netlify Account

Sign up at netlify.com using your GitHub, GitLab, or email.
2

Deploy via Drag-and-Drop

  1. Navigate to the Netlify dashboard
  2. Drag your public folder directly onto the deployment zone
  3. Wait for deployment to complete
Your site will be live at: https://random-name-123.netlify.app
3

Configure Site Settings

  1. Click Site settings
  2. Change site name to something memorable (e.g., stockpro-yourcompany)
  3. Your new URL: https://stockpro-yourcompany.netlify.app

Deploy with Netlify CLI

For automated deployments:
# Install Netlify CLI
npm install -g netlify-cli

# Login
netlify login

# Deploy
cd ~/workspace/source/public
netlify deploy --prod

Custom Domain Setup (Netlify)

1

Navigate to Domain Settings

Site settings → Domain management → Add custom domain
2

Add Your Domain

Enter your domain (e.g., stockpro.yourdomain.com)
3

Configure DNS

Add CNAME record in your DNS provider:
CNAME    stockpro    stockpro-yourcompany.netlify.app
Or for apex domains, use Netlify’s nameservers:
dns1.p05.nsone.net
dns2.p05.nsone.net
dns3.p05.nsone.net
dns4.p05.nsone.net
4

Enable HTTPS

Netlify automatically provisions SSL certificates. Wait 1-2 minutes for activation.

Option 3: Vercel

Vercel provides fast global deployment with edge network optimization.
1

Create Vercel Account

Sign up at vercel.com using GitHub, GitLab, or email.
2

Install Vercel CLI

npm install -g vercel
3

Deploy

cd ~/workspace/source/public
vercel --prod
Follow the prompts:
  • Set up and deploy: Yes
  • Link to existing project: No
  • Project name: stockpro
  • Directory: ./ (current directory)

Custom Domain Setup (Vercel)

1

Navigate to Project Settings

Vercel Dashboard → Your Project → Settings → Domains
2

Add Domain

Enter your domain and click Add
3

Configure DNS

Add the provided DNS records to your domain registrar:
A    @    76.76.21.21
Or for subdomains:
CNAME    stockpro    cname.vercel-dns.com

Production Configuration

Update Firebase Configuration

Ensure public/js/firebase.js uses your production Firebase project:
const firebaseConfig = {
  apiKey: "YOUR_PRODUCTION_API_KEY",
  authDomain: "stockpro-prod.firebaseapp.com",
  projectId: "stockpro-prod",
  storageBucket: "stockpro-prod.firebasestorage.app",
  messagingSenderId: "YOUR_SENDER_ID",
  appId: "YOUR_APP_ID",
  measurementId: "YOUR_MEASUREMENT_ID"
};
Do not use development or staging Firebase credentials in production!

Authorize Production Domain

Add your production domain to Firebase authorized domains:
1

Navigate to Authentication Settings

Firebase Console → Authentication → Settings → Authorized domains
2

Add Domain

Click Add domain and enter your production URL:
  • stockpro.yourdomain.com
  • your-project.web.app (Firebase Hosting)
  • stockpro-company.netlify.app (Netlify)
  • stockpro.vercel.app (Vercel)

Set Firestore Security Rules

Before going live, deploy production security rules:
firebase deploy --only firestore:rules
See Security Rules for detailed configuration.

Build Process

StockPro is a static site with no build step required. However, if you want to add optimization:

Optional: Minification

Minify JavaScript and CSS for better performance:
# Install minification tools
npm install -g terser clean-css-cli html-minifier

# Create optimized build
mkdir -p dist

# Copy and minify files
cp -r public/* dist/

find dist -name '*.js' -exec terser {} -o {} \;
find dist -name '*.css' -exec cleancss -o {} {} \;
find dist -name '*.html' -exec html-minifier --collapse-whitespace --remove-comments {} -o {} \;

# Deploy dist folder instead of public

Optional: Environment Variables

For managing multiple environments, use a build script:
import fs from 'fs';

const env = process.env.NODE_ENV || 'development';
const config = {
  development: {
    apiKey: process.env.DEV_FIREBASE_API_KEY,
    projectId: 'stockpro-dev'
  },
  production: {
    apiKey: process.env.PROD_FIREBASE_API_KEY,
    projectId: 'stockpro-prod'
  }
};

const firebaseConfig = config[env];

// Generate firebase.js with environment-specific config
const template = `
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js";
import { getAuth } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-auth.js";
import { getFirestore } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-firestore.js";

const firebaseConfig = ${JSON.stringify(firebaseConfig, null, 2)};

const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getFirestore(app);

export { auth, db };
`;

fs.writeFileSync('public/js/firebase.js', template);
console.log(`Built for ${env}`);

Post-Deployment Verification

After deployment, verify everything works:
1

Test Authentication

  1. Navigate to your production URL
  2. Try logging in with a test account
  3. Verify authentication redirects work correctly
2

Test Firestore Access

  1. Check that data loads correctly
  2. Verify create/update/delete operations
  3. Confirm security rules are enforced
3

Check Browser Console

Open developer tools and check for:
  • No JavaScript errors
  • No Firebase configuration errors
  • No CORS or security warnings
4

Test All Features

Go through your application workflow:
  • User authentication
  • Inventory management
  • POS functionality
  • Reports and analytics

Rollback Strategy

Firebase Hosting Rollback

# View deployment history
firebase hosting:channel:list

# Rollback to previous version
firebase hosting:rollback

Netlify Rollback

  1. Go to Netlify Dashboard → Deploys
  2. Find previous working deployment
  3. Click options menu → Publish deploy

Vercel Rollback

  1. Go to Vercel Dashboard → Deployments
  2. Find previous working deployment
  3. Click Promote to Production

Continuous Deployment

GitHub Actions (Firebase)

Automate deployments with GitHub Actions:
.github/workflows/deploy.yml
name: Deploy to Firebase Hosting

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Deploy to Firebase
        uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: '${{ secrets.GITHUB_TOKEN }}'
          firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}'
          channelId: live
          projectId: your-project-id

Git Integration (Netlify/Vercel)

Both Netlify and Vercel offer automatic deployments from Git:
1

Connect Git Repository

Link your GitHub, GitLab, or Bitbucket repository
2

Configure Build Settings

  • Base directory: Leave empty
  • Build command: Leave empty (no build needed)
  • Publish directory: public
3

Enable Auto Deploy

Every push to your main branch will trigger automatic deployment

Monitoring and Analytics

Firebase Analytics

Track user behavior with Firebase Analytics:
public/js/firebase.js
import { getAnalytics } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-analytics.js";

const analytics = getAnalytics(app);
export { auth, db, analytics };

Performance Monitoring

Monitor app performance:
import { getPerformance } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-performance.js";

const perf = getPerformance(app);

Troubleshooting

Deployment Succeeds but Site Shows Old Version

Cause: Browser caching or CDN cache Solution:
  • Clear browser cache (Ctrl+Shift+R)
  • Wait 5-10 minutes for CDN propagation
  • Use cache-busting query parameters: ?v=2

”Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR”

Cause: SSL certificate not yet provisioned Solution: Wait 24 hours for SSL certificate provisioning, then refresh.

Authentication Works Locally but Not in Production

Cause: Production domain not authorized in Firebase Solution: Add domain to Firebase Console → Authentication → Settings → Authorized domains

Next Steps

Security Rules

Secure your production Firestore database

Dashboard Metrics

Monitor your sales and inventory metrics

Build docs developers (and LLMs) love