Skip to main content

Configuration

Configuration - 中通天鸿 Docs

Learn how to configure Virex for your project. Covers build settings, environment variables, and deployment options.

Virex is configured through a virex.config.js file in your project root. This guide covers all available options.

Basic Configuration

A minimal configuration looks like this:

export default {
  name: 'my-project',
};

Virex auto-detects most settings, but you can override them as needed.

Build Settings

Control how your project is built:

export default {
  name: 'my-project',
  
  // Build configuration
  buildCommand: 'npm run build',
  installCommand: 'npm ci',
  outputDirectory: 'dist',
  
  // Node.js version
  nodeVersion: '20',
};

Framework Detection

Virex automatically detects popular frameworks:

  • Next.js
  • Astro
  • Remix
  • SvelteKit
  • Nuxt
  • And many more

Override detection with the framework option:

framework: 'astro',

Environment Variables

Define environment variables for your deployments:

export default {
  name: 'my-project',
  
  env: {
    PUBLIC_API_URL: 'https://api.example.com',
  },
};

Sensitive Variables

For secrets, use the CLI or dashboard instead of committing to code:

virex env add DATABASE_URL "postgres://..." --environment production

Environment-Specific Variables

Different values for different environments:

environments: {
  staging: {
    env: {
      PUBLIC_API_URL: 'https://staging-api.example.com',
    },
  },
  production: {
    env: {
      PUBLIC_API_URL: 'https://api.example.com',
    },
  },
},

Deployment Settings

Configure deployment behavior:

export default {
  name: 'my-project',
  
  // Deployment settings
  regions: ['us-east-1', 'eu-west-1'],
  
  // Health checks
  healthCheck: {
    path: '/api/health',
    interval: 30,
  },
  
  // Automatic rollback on failure
  rollback: {
    automatic: true,
  },
};

Headers and Redirects

Configure HTTP headers and redirects:

export default {
  name: 'my-project',
  
  headers: [
    {
      source: '/(.*)',
      headers: [
        { key: 'X-Frame-Options', value: 'DENY' },
      ],
    },
  ],
  
  redirects: [
    {
      source: '/old-page',
      destination: '/new-page',
      permanent: true,
    },
  ],
};

Full Example

Here’s a complete configuration example:

export default {
  name: 'my-saas-app',
  framework: 'astro',
  
  buildCommand: 'npm run build',
  outputDirectory: 'dist',
  nodeVersion: '20',
  
  env: {
    PUBLIC_SITE_URL: 'https://myapp.com',
  },
  
  environments: {
    staging: {
      env: {
        PUBLIC_SITE_URL: 'https://staging.myapp.com',
      },
    },
  },
  
  regions: ['us-east-1'],
  
  healthCheck: {
    path: '/api/health',
    interval: 30,
  },
};

Next Steps

在线咨询 在线咨询
热线电话 热线电话 热线电话 热线电话
免费热线 400-668-3333
微信咨询 微信咨询 微信咨询 微信咨询
微信二维码 专家一对一沟通 免费获取专属方案
体验demo 体验demo 体验demo 体验demo 免费试用 免费试用 免费试用 免费试用
回顶部 回顶部 回顶部 回顶部
热线电话 热线电话
在线咨询 在线咨询
微信咨询 微信咨询
体验demo 体验demo 免费试用 免费试用
0元免费试用,立即领取免费试用机会! 0元免费试用, 立即领取免费试用机会! 免费试用