v3/goal_ui/docs/DEPLOYMENT.md
Before deploying, ensure:
Widget files are built: Run npm run build
dist/ folderRequired files in dist/:
widget.js (595KB)widget.css (65KB)widget-embed.html_headers (CORS configuration)_redirects (routing rules)Verify locally:
npm run build
npm run preview
# Visit http://localhost:4173/demo
Ensure your Netlify site has these build settings:
npm run builddistNODE_VERSION=18)Push to Git:
git add .
git commit -m "Add widget embed system"
git push origin main
Netlify will automatically:
npm installnpm run builddist/ folder_headers and _redirects rulesVerify deployment:
https://your-domain.com/widget.js - should return JavaScripthttps://your-domain.com/widget.css - should return CSShttps://your-domain.com/demo - should load widget demohttps://your-domain.com/widget-embed.html - should show embed exampleSymptom: widget.js and widget.css return 404
Solutions:
Check build logs:
Verify _redirects file:
_redirects file exists in deployed siteClear Netlify cache:
# In Netlify dashboard:
Site settings > Build & deploy > Clear cache and retry deploy
Manual verification:
# Locally verify build output
npm run build
ls -la dist/ | grep widget
# Should show widget.js, widget.css, widget-embed.html
Symptom: Widget loads on same domain but fails on external sites
Solution: Verify _headers file contains:
/widget.js
Access-Control-Allow-Origin: *
Content-Type: application/javascript; charset=utf-8
/widget.css
Access-Control-Allow-Origin: *
Content-Type: text/css; charset=utf-8
Symptom: Direct URLs to /demo return 404
Solution: The _redirects file should have the SPA fallback as the LAST rule:
/* /index.html 200
If automatic deployment fails, you can build and deploy manually:
# 1. Build locally
npm run build
# 2. Verify files
ls -la dist/ | grep -E "(widget|_headers|_redirects)"
# 3. Deploy via Netlify CLI
npm install -g netlify-cli
netlify deploy --prod --dir=dist
Once deployed, your widget will be available at:
https://your-domain.com/widget.jshttps://your-domain.com/widget.csshttps://your-domain.com/demohttps://your-domain.com/widget-embed.htmlShare this code with users who want to embed the widget:
<!-- RuFlo Research Widget Container -->
<div id="ruflo-research-widget-container"></div>
<!-- Configuration (optional) -->
<script>
window.RufloResearchWidgetConfig = {
primaryColor: "#8b5cf6",
accentColor: "#22c55e",
backgroundColor: "#1a1a1a"
};
</script>
<!-- Load Widget -->
<link rel="stylesheet" href="https://your-domain.com/widget.css">
<script src="https://your-domain.com/widget.js"></script>
No environment variables are required for the widget to work. However, if you're using Supabase functions, ensure these are set in Netlify:
VITE_SUPABASE_URLVITE_SUPABASE_ANON_KEYAfter deployment, test:
/demo, verify widget loads/widget.js and /widget.css/widget-embed.htmlMonitor widget usage:
/widget.js and /widget.css requestsWhen you make changes:
npm run build locally to testThe _headers file sets:
max-age=31536000)To force users to get new version:
widget.v2.js)