Astro Configuration
The portfolio usesastro.config.mjs for all build and site configuration.
Configuration File
Configuration Options Explained
site - The base URL of your deployed site
- Used for generating absolute URLs in sitemaps and meta tags
- Format:
https://yourdomain.com(include protocol, no trailing slash) - Critical for SEO and social media sharing
integrations - Astro integrations that extend functionality
icon(): Enables the astro-icon integration for icon supportsitemap(): Automatically generates sitemap.xml for SEO
vite.plugins - Vite plugins for the build process
tailwindcss(): Processes Tailwind CSS styles via Vite (TailwindCSS v4)
This portfolio uses TailwindCSS v4 which integrates as a Vite plugin instead of PostCSS, providing better performance and simpler configuration.
Build Process
The build process is defined inpackage.json and executed by the GitHub Actions workflow.
Build Scripts
package.json
npm run build- Builds the production site todist/npm run dev- Starts development server (usually on port 4321)npm run preview- Previews the production build locallynpm run check:types- Type-checks TypeScript without emitting files
Build Output
When you runastro build, Astro:
Processes styles
- Compiles TailwindCSS via Vite plugin
- Minifies CSS for production
- Generates optimized stylesheets
Optimizes assets
- Bundles and minifies JavaScript
- Optimizes images (if image optimization is configured)
- Generates content hashes for cache busting
Integrations
The portfolio uses several Astro integrations to enhance functionality.Icon Integration
@iconify-json/mdi- Material Design Icons@iconify-json/simple-icons- Brand and logo icons
Sitemap Integration
- Generates
sitemap-index.xmlat build time - Uses the
siteconfiguration for absolute URLs - Includes all static pages automatically
- Helps with SEO and search engine discoverability
TailwindCSS Configuration
The portfolio uses TailwindCSS v4, which has a simpler configuration approach.Integration Method
Tailwind is integrated as a Vite plugin:astro.config.mjs
Unlike TailwindCSS v3, version 4 does not require a separate
tailwind.config.js file. Configuration is handled through CSS and the Vite plugin.Dependencies
Tailwind-related packages:Build Optimization
Performance Optimizations
The build includes several automatic optimizations:- Static Site Generation (SSG): All pages are pre-rendered at build time
- Code splitting: JavaScript is automatically split for optimal loading
- CSS minification: Styles are minified and optimized
- Asset hashing: Cache-busting hashes for all assets
- Tree shaking: Unused code is removed from bundles
SEO Optimizations
Sitemap generation:- Automatically created via
@astrojs/sitemap - Uses correct absolute URLs from
siteconfig - Updates on every build
- Uses
astro-seopackage for SEO meta tags (installed as dependency) - Supports Open Graph and Twitter Card tags
- Configurable per page
Customizing the Build
Changing the Site URL
Update thebase constant in astro.config.mjs:
astro.config.mjs
Adding Output Options
For deploying to platforms other than GitHub Pages, you may need an adapter:astro.config.mjs
The current configuration uses the default
static output mode, which is perfect for GitHub Pages deployment.Adding Base Path
If deploying to a subdirectory (e.g.,https://username.github.io/portfolio/):
astro.config.mjs
Environment Variables
The current portfolio does not use any environment variables. However, if you need to add them, here’s how:
Adding Environment Variables
Create a.env file in the repository root:
.env
- Variables prefixed with
PUBLIC_are exposed to client-side code - Variables without
PUBLIC_are only available server-side - Never commit
.envfiles to version control
Using in Code
GitHub Actions Secrets
For environment variables in CI/CD:Troubleshooting
Build Fails Locally
Steps to debug:-
Clear cache and reinstall dependencies:
-
Check for TypeScript errors:
-
Run linter:
Sitemap Not Generating
Check these items:@astrojs/sitemapis installed and listed in integrationssiteconfig is set inastro.config.mjs- Build completed successfully
- Check
dist/sitemap-index.xmlafter building
Styles Not Applying
TailwindCSS v4 troubleshooting:- Verify
@tailwindcss/viteis in vite.plugins - Check that Tailwind directives are in your CSS file
- Ensure class names are correct and not purged
- Clear build cache:
rm -rf .astro dist
Build Works Locally But Fails in CI
Common causes:- Different Node versions: Check Node version in workflow vs local
- Missing dependencies: Ensure all deps are in
package.json, not installed globally - Case-sensitive imports: Linux (CI) is case-sensitive, macOS/Windows are not
- Environment variables: May be missing in CI environment
The GitHub Actions workflow uses the latest Ubuntu runner and automatically installs the correct Node version based on your project configuration.
