Blog>
Snippets

Integrating TanStack Config with CI/CD Pipelines

Illustrate a practical example of how TanStack Config can be integrated into CI/CD pipelines, emphasizing automation of environment setups.
const { defineConfig } = require('@tanstack/config');

exports.config = defineConfig({
  env: process.env.NODE_ENV,
  // Define environment-specific configurations
  development: {
    apiUrl: 'https://dev.api.example.com',
    featureFlag: true
  },
  production: {
    apiUrl: 'https://prod.api.example.com',
    featureFlag: false
  }
});
This code snippet defines a basic configuration for a project using @tanstack/config. It demonstrates how to set up different configurations for the development and production environments, which can be automatically selected based on the NODE_ENV environment variable typically used in CI/CD pipelines.
// CI/CD Pipeline Script Example

// Assume this part is a portion of a CI/CD pipeline configuration file
steps:
- name: Install dependencies
  command: 'npm install'
- name: Set Node Environment
  command: 'export NODE_ENV=production'
- name: Build
  command: 'npm run build'
This pseudo code represents a section of a CI/CD pipeline script where the Node environment is set, triggering the use of the production environment settings from the previous code snippet during the build process. This example shows how TanStack Config integrates seamlessly into CI/CD workflows by adjusting configurations based on the environment variable.