Blog>
Snippets

Implementing Continuous Integration (CI) with TanStack Config

Show how to set up a basic CI pipeline using TanStack Config, focusing on automating tests and ensuring code quality standards are met before deployment.
const { defineConfig } = require('tanstack-config-vite');
First, import the 'defineConfig' function from 'tanstack-config-vite' to start defining our CI pipeline configuration.
// Define the CI configuration
module.exports = defineConfig({
  plugins: [
    // Add plugins for code quality checks (e.g., ESLint, Prettier)
  ],
  test: {
    // Configure testing environment
    globals: true,
    environment: 'jsdom'
  },
  build: {
    // Configuration for the build process
    outDir: 'dist',
    rollupOptions: {},
    minify: 'terser' // Minify output using terser
  },
  publish: {
    // Publish configuration for NPM and GitHub
    npm: true,
    github: true
  }
});
Then, we configure the CI pipeline using 'defineConfig'. This includes plugin configurations for enforcing code quality (e.g., linting and formatting), setting up a testing environment, configuring the build process (including output directory and minification), and specifying publishing options for npm and GitHub.
// Example plugin usage
const eslintPlugin = require('@vitejs/plugin-eslint');

// Add the ESLint plugin in the plugins array
plugins: [
  eslintPlugin()
],
This is an example of how to add a plugin, specifically an ESLint plugin, to the pipeline for checking code quality automatically during the CI process.