package.json for common development tasks.
Development Commands
npm run dev
Starts the Astro development server with hot module replacement.
- Launches dev server at
http://localhost:4321 - Watches for file changes in
src/ - Automatically rebuilds and reloads the browser
- Enables Astro dev toolbar for debugging
- Serves unoptimized builds for faster iteration
- Active development and coding
- Testing changes in real-time
- Debugging with browser DevTools
The dev server supports custom ports with
npm run dev -- --port 3000. The -- passes arguments to the underlying Astro CLI.Production Commands
npm run build
Creates an optimized production build of the site.
- Compiles all
.astrofiles to HTML - Bundles and minifies JavaScript/CSS
- Optimizes images and assets
- Generates static files in the
dist/directory - Runs type checking (TypeScript)
- Tree-shakes unused code
- Before deploying to production
- Testing production performance locally
- Verifying build succeeds without errors
- Checking final bundle sizes
- All production files are written to
dist/ - The
dist/directory contains the complete static site ready for deployment
npm run preview
Serves the production build locally for testing.
- Serves the
dist/directory (must runbuildfirst) - Starts a local server at
http://localhost:4321 - Simulates production environment
- Does not watch for changes or rebuild
- Testing production build before deployment
- Verifying optimizations worked correctly
- Checking that all assets load properly
- Performance testing with production bundles
If you make changes to source files, you must run
npm run build again before those changes appear in preview mode.Astro CLI
npm run astro
Provides direct access to the Astro CLI for advanced commands.
- Runs any Astro CLI command
- Useful for advanced configuration and troubleshooting
Command Comparison
dev
Development
- Hot reload
- Fast builds
- Debug tools
- Unoptimized
build
Production Build
- Optimized output
- Minified assets
- Type checking
- Creates
dist/
preview
Preview Build
- Serves
dist/ - Production mode
- No file watching
- Must build first
Typical Workflows
Daily Development
Pre-Deployment Testing
Troubleshooting
No Test Suite
This project does not currently have automated tests configured. Manual testing via
npm run dev and npm run preview is the primary quality assurance method.- Vitest for unit tests
- Playwright or Cypress for E2E tests
- Lighthouse CI for performance testing