Building and Deploying React Web Apps with OneDev

A complete guide to setting up automated CI/CD pipelines for React applications, from project setup to production deployment.

Modern React development requires robust CI/CD pipelines that automate testing, building, and deployment workflows. OneDev provides an integrated solution for managing the entire application lifecycle, from code commit to production deployment. This guide covers setting up automated build processes, configuring test pipelines, and implementing deployment strategies that ensure reliable, repeatable releases. By implementing proper CI/CD practices, development teams can reduce deployment time by up to 80% while minimizing human error in release processes.

What You'll Learn

Modern Project Setup

Initialize React projects with Vite and TypeScript for optimal development experience

CI/CD Pipeline Configuration

Configure OneDev pipelines with automated testing and build stages

Deployment Strategies

Implement environment promotion and zero-downtime deployment workflows

Performance Optimization

Optimize production builds with code splitting and bundle analysis

Setting Up Your React Project with Modern Tooling

Modern React project setup has evolved significantly with tools like Vite offering superior development server performance and optimized production builds. The Create React App approach has been largely superseded by Vite, which provides instant server start, hot module replacement, and native ES module support. TypeScript integration is now considered standard practice for production applications, providing type safety that catches errors during development rather than runtime.

Project Initialization with Vite

The Vite CLI provides a streamlined project creation experience. Running npm create vite@latest my-react-app -- --template react-ts generates a complete React TypeScript project with optimized build configurations. The resulting structure includes dedicated directories for components, assets, and utility functions, promoting organized code architecture.

Environment Configuration

Environment-specific configuration is managed through .env files that load variables based on the current environment (development, staging, production). React applications access these variables through import.meta.env, with variables prefixed by VITE_ for client-side exposure.

Vite Project Setup Command
1# Create a new React TypeScript project with Vite2npm create vite@latest my-react-app -- --template react-ts3 4# Project structure generated:5# my-react-app/6# ├── src/7# │ ├── components/8# │ ├── assets/9# │ ├── App.tsx10# │ └── main.tsx11# ├── public/12# ├── package.json13# ├── tsconfig.json14# └── vite.config.ts

OneDev CI/CD Pipeline Architecture

OneDev is a self-hosted GitLab alternative that provides integrated CI/CD capabilities with Docker support, making it ideal for managing React application build and deployment pipelines. The platform's pipeline configuration uses YAML files committed to the repository, enabling version-controlled CI/CD workflows that track changes alongside application code.

For teams looking to implement comprehensive automation workflows, OneDev provides the foundation for automated testing, building, and deployment without requiring external services or recurring subscription costs. This self-hosted approach gives full control over infrastructure while maintaining enterprise-grade reliability.

Pipeline Configuration Basics

OneDev pipelines are defined in .onedev/pipelines or .onedev.yaml at the repository root. The configuration defines stages (build, test, deploy), jobs within each stage, and the conditions for job execution.

Build Job Configuration

The build job orchestrates dependency installation and production build generation. OneDev's caching mechanisms dramatically reduce build times by preserving node_modules between runs.

OneDev Pipeline Configuration
1pipeline:2 name: React CI/CD Pipeline3 stages:4 - name: Install5 jobs:6 - name: dependencies7 image: node:208 steps:9 - name: Install dependencies10 run: npm ci11 cache: true12 13 - name: Test14 jobs:15 - name: unit-tests16 image: node:2017 steps:18 - name: Run tests19 run: npm test -- --watchAll=false20 - name: Generate coverage21 run: npm test -- --coverage22 23 - name: Build24 jobs:25 - name: production-build26 image: node:2027 steps:28 - name: Build for production29 run: npm run build30 - name: Upload artifacts31 upload: dist/**/*32 33 - name: Deploy34 jobs:35 - name: deploy-staging36 image: node:2037 conditions:38 - branch: develop39 steps:40 - name: Deploy to staging41 run: npm run deploy:staging42 - name: deploy-production43 image: node:2044 conditions:45 - tag: v*.*.*46 steps:47 - name: Deploy to production48 run: npm run deploy:production

Automated Testing Integration

Automated testing within CI/CD pipelines ensures code quality gates prevent regressions from reaching production. The testing stage executes unit tests, integration tests, and optionally end-to-end tests, with the pipeline failing if any test suite returns errors.

Test Scripts and Coverage

React projects typically include test scripts configured in package.json. Running npm test executes test suites using testing frameworks like Vitest and React Testing Library. Coverage reports generated through tools like V8 coverage provider identify untested code paths, helping teams maintain comprehensive test coverage. Quality thresholds can be configured to fail builds when coverage falls below defined percentages.

Package.json Test Configuration
1{2 "scripts": {3 "dev": "vite",4 "build": "tsc && vite build",5 "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",6 "preview": "vite preview",7 "test": "vitest",8 "test:coverage": "vitest run --coverage"9 },10 "vitest": {11 "coverage": {12 "provider": "v8",13 "reporter": ["text", "json", "html"],14 "lines": 80,15 "functions": 80,16 "branches": 80,17 "statements": 8018 }19 }20}

Deployment Strategies for React Applications

React applications are typically deployed as static assets served from CDN infrastructure, making deployment straightforward while still requiring careful configuration for environment promotion and rollback capabilities. OneDev supports various deployment targets including traditional servers, containerized environments, and cloud platforms.

Environment-Specific Deployments

Each deployment environment requires specific configuration and credentials. Development deployments provide rapid feedback for feature development. Staging environments mirror production configuration for integration testing. Production deployments follow controlled promotion workflows with validation gates ensuring only tested code reaches users.

Build Artifact Management

Build artifacts should be versioned and retained for rollback purposes. Semantic versioning or commit-based versioning enables precise artifact identification. Teams implementing comprehensive DevOps practices see significantly faster release cycles and more reliable deployments.

Performance Optimization in Production Builds

Production builds require optimization beyond development builds, including minification, tree shaking, and code splitting. Bundle analysis tools identify large dependencies and opportunities for optimization, while performance monitoring in production environments validates optimization effectiveness.

Bundle Optimization Techniques

Code splitting through dynamic imports reduces initial bundle size by loading code on demand. Lazy loading components and routes ensures users download only necessary code for their current view. Tree shaking eliminates unused exports from production bundles, while chunk optimization groups related code for efficient loading patterns.

Build Analysis and Monitoring

Tools like Vite's built-in analyzer or rollup-plugin-visualizer provide visual representations of bundle composition, identifying large dependencies and optimization opportunities. Performance budgets establish acceptable thresholds for bundle size, script execution time, and Core Web Vitals. For teams focused on SEO performance alongside application performance, implementing proper optimization techniques ensures both search rankings and user experience benefit from optimized builds.

Lazy Loading Implementation
1import { lazy, Suspense } from 'react';2import LoadingSpinner from './components/LoadingSpinner';3 4// Lazy load heavy components5const VideoEditor = lazy(() => import('./components/VideoEditor'));6const ChartLibrary = lazy(() => import('./components/ChartLibrary'));7 8function Dashboard() {9 return (10 <div className="dashboard">11 <Suspense fallback={<LoadingSpinner />}>12 <VideoEditor />13 </Suspense>14 15 <Suspense fallback={<LoadingSpinner />}>16 <ChartLibrary />17 </Suspense>18 </div>19 );20}21 22export default Dashboard;

Best Practices for CI/CD Success

Successful CI/CD pipelines balance speed, reliability, and security. Pipeline efficiency requires optimizing job execution order, implementing parallel execution where possible, and maintaining fast feedback loops.

Pipeline Optimization Strategies

  • Parallel execution: Run independent jobs simultaneously to maximize throughput
  • Smart caching: Preserve dependencies and build artifacts between runs
  • Incremental builds: Skip unnecessary work when source changes don't require complete rebuilds

Security and Compliance

CI/CD pipelines require access to sensitive credentials for deployment and testing. OneDev's secure storage prevents credential exposure, while access controls limit pipeline modification permissions to authorized team members. Regular security audits and dependency vulnerability scanning protect the deployment pipeline from potential threats.

Frequently Asked Questions

Ready to Optimize Your React Development Workflow?

Our team specializes in building modern React applications with automated CI/CD pipelines for reliable, scalable deployments.

Sources

  1. LogRocket: Build and deploy a React web app with OneDev - Comprehensive CI/CD pipeline setup with OneDev
  2. React.dev: Creating a React App - Official React guidance on modern project setup
  3. DEV Community: The 2025 Guide to Building Scalable React Apps - Modern React architecture patterns
  4. DEV Community: React Performance Optimization 15 Best Practices for 2025 - Performance optimization techniques