{"id":32788148,"url":"https://github.com/miacias-concorde/bootstrap-migration","last_synced_at":"2026-05-13T20:33:27.680Z","repository":{"id":311668335,"uuid":"1044514346","full_name":"miacias-concorde/bootstrap-migration","owner":"miacias-concorde","description":"Proof of Concept using PostCSS to implement simultaneous Bootstrap versions; designed to have granular control over migrating from version 4 to 5 and mitigate breaking changes","archived":false,"fork":false,"pushed_at":"2025-08-26T14:16:21.000Z","size":448,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-05T07:02:06.044Z","etag":null,"topics":["bootstrap","bootstrap4","bootstrap5"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miacias-concorde.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-25T19:56:01.000Z","updated_at":"2025-08-26T14:16:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"e92b3208-28c3-4b5f-b8c9-9f81e2296944","html_url":"https://github.com/miacias-concorde/bootstrap-migration","commit_stats":null,"previous_names":["miacias-concorde/bootstrap-migration"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/miacias-concorde/bootstrap-migration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miacias-concorde%2Fbootstrap-migration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miacias-concorde%2Fbootstrap-migration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miacias-concorde%2Fbootstrap-migration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miacias-concorde%2Fbootstrap-migration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miacias-concorde","download_url":"https://codeload.github.com/miacias-concorde/bootstrap-migration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miacias-concorde%2Fbootstrap-migration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32999360,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"ssl_error","status_checked_at":"2026-05-13T13:14:51.610Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bootstrap","bootstrap4","bootstrap5"],"created_at":"2025-11-05T07:01:02.520Z","updated_at":"2026-05-13T20:33:27.674Z","avatar_url":"https://github.com/miacias-concorde.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bootstrap Migration Proof of Concept\n\nThis project demonstrates how to use both Bootstrap v4 and v5 side-by-side in a modern React/Vite application. It showcases scoping of Bootstrap versions using PostCSS, allowing legacy Bootstrap 4 components and new Bootstrap 5 components to coexist without style conflicts.\n\n## Key Features\n\n- **Bootstrap v4 and v5 loaded together**: Bootstrap 5 is installed via npm; Bootstrap 4 is downloaded as a static asset.\n- **Scoped CSS**: PostCSS with `postcss-prefixwrap` is used to namespace each version (`.bs4` for v4, `.bs5` for v5), preventing style collisions. Components without a prefix will receive neither set of styles.\n- **One import**: Import the migration Bootstrap CSS from one stylesheet `\u003clink rel=\"stylesheet\" href=\"/bootstrap-migration.css\" /\u003e`, which can later be ejected once v4 and PostCSS prefixes are removed\n- **Migration-friendly**: Easily migrate components from v4 to v5 by changing their wrapper class.\n- **React + Vite**: Fast development environment with hot module replacement.\n\n## How It Works\n\n- Bootstrap 4 and 5 CSS and JS are downloaded and placed in the `public` folder.\n- Bootstrap 5 is installed via npm and imported in the app as a staged package to be used once the migration is complete\n- PostCSS processes the CSS to scope each version.\n- Components are wrapped in either `.bs4` or `.bs5` via a reusable `Bootstrap` component to apply the correct styles.\n\n## Why?\n\nThis setup is ideal for teams migrating large codebases from Bootstrap 4 to 5, allowing gradual migration and easy comparison of styles and features with with clear style separation and minimal conflicts and without fighting breaking changes.\n\n\n## Migration Steps\n\n1. Follow this setup guide to create PostCSS Bootstrap 4 and Bootstrap 5 prefixes and a wrapper component\n2. Wrap all components in Bootstrap 4\n3. Begin converting all component syntax and wrappers to Bootstrap 5\n4. Eject Bootstrap 4\n5. Remove PostCSS Bootstrap 5 prefix and Bootstrap 5 wrappers (rely on Node package)\n\n\n## Usage\n\n1. Install dependencies: `npm install`\n2. Download Bootstrap 4 and 5 assets: `npm run download:bootstrap4` and `npm run download:bootstrap5`\n3. Add v4 prefix: in `postcss.config.cjs`, comment out the `.bs5` prefix, then run `npm run scope:bootstrap4`\n4. Add v5 prefix: in `postcss.config.cjs`, comment out the `.bs4` prefix, then run `npm run scope:bootstrap5`\n5. Build combined scoped CSS: `npm run build:css`\n6. Start the app: `npm run dev`\n\n## How to Set Up Bootstrap v4 and v5 Scoping in Any Project\n\nFollow these steps to recreate the migration proof of concept in your own repository:\n\n1. **Initialize your project**\n   \n   Create a new project folder and initialize with your preferred frontend stack (e.g., React + Vite):\n\n     ```bash\n     npm create vite@latest my-app -- --template react\n     cd my-app\n     npm install\n     ```\n\n2. **Install Bootstrap v5 via npm**\n\n   Note: This is not used during migration and only used after v4 and PostCSS prefixing is ejected.\n\n   ```bash\n   npm install bootstrap\n   ```\n\n3. **Download Bootstrap v4 as scoped assets**\n   \n   Download the CSS and JS files from the official CDN:\n\n     ```bash\n     curl -o public/bootstrap4-scoped.css https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css\n\n     curl -o public/bootstrap4-scoped.bundle.min.js https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js\n\n     curl -o public/bootstrap5.css https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css\n\n     curl -o public/bootstrap5.bundle.min.js https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js\n     ```\n\n4. **Install PostCSS and postcss-prefixwrap**\n   ```bash\n   npm install --save-dev postcss postcss-cli postcss-prefixwrap sass\n   ```\n\n5. **Configure PostCSS**\n   \n   Create `postcss.config.cjs` in your project root:\n\n   NOTE: only one prefix can be ran at a time, which means that one or the other `prefixWrap()` will always need to be commented out when running script commands.\n\n     ```js\n     const prefixWrap = require('postcss-prefixwrap');\n     module.exports = {\n       plugins: [\n         prefixWrap('.bs4'),\n         prefixWrap('.bs5'),\n       ],\n     };\n     ```\n\n6. **Create a migration SCSS file that can later be ejected**\n   \n   Example: `src/styles/bootstrap-migration.scss`\n\n     ```scss\n     @use \"bootstrap/scss/bootstrap\" as *;\n     @import \"../public/bootstrap4.css\";\n     ```\n\n7. **Build the migration CSS**\n   \n   Add a script to your `package.json`:\n\n     ```json\n     \"build:css\": \"cat public/bootstrap4-scoped.css public/bootstrap5-scoped.css \u003e public/bootstrap-migration.css\"\n     ```\n\n   - Run:\n     ```bash\n     npm run build:css\n     ```\n\n8. **Reference the migration CSS in your HTML**\n   \n   Add to your `index.html`:\n\n     ```html\n     \u003clink rel=\"stylesheet\" href=\"/bootstrap-migration.css\" /\u003e\n     ```\n\n9. **Scope your components**\n   - Create a reusable component that takes in a `version` and `children` which prefixes with either version 4 or 5 of Bootstrap\n      - Wrap Bootstrap 4 components in `\u003cdiv class=\"bs4\"\u003e...\u003c/div\u003e`\n      - Wrap Bootstrap 5 components in `\u003cdiv class=\"bs5\"\u003e...\u003c/div\u003e`\n\n\n\n## Important: Scoping Bootstrap v4 and v5\n\nTo ensure styles are correctly scoped, you must update your `postcss.config.cjs` before each build step:\n\n1. **Scope Bootstrap v4:**\n   - Set your `postcss.config.cjs` to:\n     ```js\n     const prefixWrap = require('postcss-prefixwrap');\n     module.exports = { plugins: [prefixWrap('.bs4')] };\n     ```\n   - Run:\n     ```bash\n     npm run scope:bootstrap4\n     ```\n\n2. **Scope Bootstrap v5:**\n   - Change your `postcss.config.cjs` to:\n     ```js\n     const prefixWrap = require('postcss-prefixwrap');\n     module.exports = { plugins: [prefixWrap('.bs5')] };\n     ```\n   - Run:\n     ```bash\n     npm run scope:bootstrap5\n     ```\n\n3. **Combine both scoped files:**\n   - Run:\n     ```bash\n     npm run build:css\n     ```\n\n4. **Reference only the combined migration stylesheet in your HTML:**\n   ```html\n   \u003clink rel=\"stylesheet\" href=\"/bootstrap-migration.css\" /\u003e\n   ```\n\n5. **Wrap your components:**\n   - Use `\u003cdiv class=\"bs4\"\u003e...\u003c/div\u003e` for Bootstrap 4\n   - Use `\u003cdiv class=\"bs5\"\u003e...\u003c/div\u003e` for Bootstrap 5\n\n**Note:**\n- Do not import or link the original, unscoped Bootstrap CSS files anywhere else in the application.\n- All Bootstrap styles will only apply inside their respective `.bs4` or `.bs5` containers.\n- Components that are not scoped will only receive styles applied other than Bootstrap, if any (or will receive browser defaults)\n\n\n## Screenshots\n\n### Migration CSS combined file\n\n![bootstrap-migration.css](image.png)\n\n### Forms\n\n![Forms](./public/image.png)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiacias-concorde%2Fbootstrap-migration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiacias-concorde%2Fbootstrap-migration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiacias-concorde%2Fbootstrap-migration/lists"}