This guide covers deploying Concept to various hosting platforms with proper routing configuration.
We've already fixed the navigation links to work with Vite's build output. The links now point directly to the built files (e.g., /dashboard-finance.html instead of /pages/dashboards/finance.html).
npm run build
This creates a dist/ folder with:
npm run preview
Visit http://localhost:4173 to test the production build.
Automatic Setup:
npm run builddistThe _redirects file in /public handles all routing automatically.
Manual Deploy:
# Install Netlify CLI
npm install -g netlify-cli
# Build and deploy
npm run build
netlify deploy --prod --dir=dist
Create vercel.json in project root:
{
"buildCommand": "npm run build",
"outputDirectory": "dist",
"rewrites": [
{ "source": "/(.*)", "destination": "/$1" }
]
}
Deploy:
# Install Vercel CLI
npm install -g vercel
# Deploy
vercel
npm install --save-dev gh-pages
package.json:{
"scripts": {
"deploy": "npm run build && gh-pages -d dist"
}
}
npm run deploy
Already included in the build. Place in dist/ folder:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
server {
listen 80;
server_name yourdomain.com;
root /var/www/concept/dist;
location / {
try_files $uri $uri/ /index.html;
}
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
Create Dockerfile:
# Build stage
FROM node:18-alpine as build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Production stage
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Create nginx.conf:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ /index.html;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
Build and run:
docker build -t concept-dashboard .
docker run -p 8080:80 concept-dashboard
Create .env.production:
VITE_API_URL=https://api.yourdomain.com
VITE_APP_NAME=My Dashboard
Access in code:
const apiUrl = import.meta.env.VITE_API_URL;
Solution: The navigation links have been fixed to match build output. If you still see 404s:
dist/Check:
vite.config.js (should be ./)Debug:
Verify:
Nginx:
gzip on;
gzip_types text/plain text/css text/javascript application/javascript application/json;
gzip_min_length 1000;
Nginx:
# HTML files - no cache
location ~* \.(html)$ {
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
# Assets - long cache
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
Update asset URLs to use CDN:
// vite.config.js
export default defineConfig({
base: process.env.NODE_ENV === 'production'
? 'https://cdn.yourdomain.com/'
: './'
});
Add analytics to track usage:
<!-- In src/partials/layouts/scripts.hbs -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
Integrate error tracking:
// In src/js/app.js
window.addEventListener('error', (event) => {
// Send to error tracking service
});
Use tools like:
npm updatenpm auditConcept is now optimized for deployment with:
Choose your preferred hosting platform and deploy with confidence!