Skip to content

Conversation

pyanderson
Copy link

@pyanderson pyanderson commented Sep 1, 2025

Description

This pull request updates the boilerplate by migrating from Bootstrap 5 to Tailwind CSS v4 and removing Sass support, simplifying the frontend stack.
Additionally, it includes minor fixes related to the deployment process on Render, ensuring smoother and more reliable builds.

Motivation and Context

The main goal of this change is to modernize and streamline our boilerplate.

  • Tailwind CSS v4 offers a more flexible, utility-first approach that reduces the need for custom Sass and speeds up development.
  • Removing Sass eliminates unnecessary complexity and dependencies from the project.
  • Fixing the deployment issues on Render ensures that new projects based on the boilerplate deploy successfully without additional manual tweaks.

Screenshots (if appropriate):

You can access the live version here:
https://new-styling.onrender.com/

Since the deployment was done on free instances, the application may be sleeping, so it may take some time to become available.

Screenshot_20250901_183240

Steps to reproduce (if appropriate):

  • Create a new project using this branch as the template:
django-admin startproject new_styling --extension py,json,yml,yaml,toml --name Dockerfile,README.md,.env.example,.gitignore,Makefile --template=https://github.com/vintasoftware/django-react-boilerplate/archive/refs/heads/672-replace-bootstrap-with-tailwind.zip
  • Follow the setup instructions and test it locally;
  • Create a new GitHub repository and push your new project;
  • Follow the deployment instructions;
  • The first time the Blueprint is created, Render will prompt you to provide the SECRET_KEY value manually. The documentation was updated to explain this step. You can generate a new secret key by running:
python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
Screenshot_20250901_154218

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires documentation updates.
  • I have updated the documentation accordingly.
  • My change requires dependencies updates.
  • I have updated the dependencies accordingly.

Closes #672

Summary by Sourcery

Modernize the boilerplate by migrating the frontend from Bootstrap and Sass to Tailwind CSS v4, simplify asset handling, and improve deployment reliability on Render

New Features:

  • Integrate Tailwind CSS v4 with a postcss.config and base Tailwind stylesheet
  • Remove Bootstrap, React-Bootstrap, and Sass dependencies and configuration
  • Convert frontend components and Django templates to use Tailwind utility classes

Bug Fixes:

  • Switch Redis service to keyvalue in render.yaml and configure SECRET_KEY with sync:false to fix Render deployment
  • Improve Sentry sourcemap upload logic and file cleanup

Enhancements:

  • Refactor webpack config to streamline CSS loading and incorporate PostCSS for Tailwind
  • Standardize build script flags and conditional checks in render_build.sh
  • Add --rm flag to Docker compose commands to cleanup containers
  • Remove explicit compose file version declaration

Documentation:

  • Update README to reference Tailwind usage and document the required SECRET_KEY setup for Render

@pyanderson pyanderson requested a review from fjsj September 1, 2025 21:30
@pyanderson pyanderson self-assigned this Sep 1, 2025
Copy link

sourcery-ai bot commented Sep 1, 2025

Reviewer's Guide

This PR migrates the frontend styling stack from Bootstrap and Sass to Tailwind CSS v4 by updating Webpack loaders and dependencies, refactors component and template markup to use Tailwind utility classes, hardens the Render build script with safer shell syntax, and refreshes project documentation and configuration (including Render’s SECRET_KEY handling) to align with the new stack and deployment flow.

Class diagram for Home page component after Tailwind migration

classDiagram
    class Home {
      +restCheck: object | null
      +showBugComponent: boolean
      +setShowBugComponent: function
      +useEffect: function
      +render(): JSX.Element
    }
    Home : - Uses Tailwind utility classes for styling
    Home : - Replaces <Button> with <button> and Tailwind classes
Loading

Class diagram for index.html template after Tailwind migration

classDiagram
    class IndexHtml {
      +body: HTML
      +h1: HTML (class="text-5xl mb-2")
      +p: HTML (class="mb-2")
      +code: HTML (class="px-1.5 py-0.5 text-sm font-mono text-pink-600 bg-gray-100 rounded")
      +div: HTML (class="max-w-5xl mx-auto px-4")
    }
    IndexHtml : - Uses Tailwind utility classes for layout and typography
Loading

File-Level Changes

Change Details Files
Migrate styling stack from Bootstrap/Sass to Tailwind CSS
  • Reconfigured webpack loaders to drop Sass support and use css-loader with postcss for Tailwind
  • Added postcss.config.mjs and a Tailwind import file; removed existing Sass source files
  • Updated package.json: removed bootstrap/react-bootstrap/sass deps; added tailwindcss and postcss plugin
webpack.config.js
postcss.config.mjs
frontend/css/style.css
frontend/sass/**/*
package.json
Update UI components and templates with Tailwind utility classes
  • Replaced Bootstrap classes in Home.tsx with Tailwind typography, spacing, and button utilities
  • Adjusted index.html wrapper, headings, code blocks, and container divs to use Tailwind classes
frontend/js/pages/Home.tsx
backend/templates/common/index.html
Harden and simplify the Render build script
  • Switched to /usr/bin/env bash shebang and unified conditionals to [[ var:- ]] syntax
  • Applied -f flag for safe file removal and standardized set -Eeuo pipefail flags
render_build.sh
Refresh project docs and configuration for the new stack and deployment
  • Updated README to reference Tailwind styling and documented SECRET_KEY sync:false setup on Render
  • Modified render.yaml, docker-compose.yml, Makefile, backend settings, and pyproject.toml to remove old services, adjust static paths, and enable manual SECRET_KEY handling
README.md
render.yaml
docker-compose.yml
Makefile
backend/project_name/settings/base.py
pyproject.toml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Make sure you import the new Tailwind CSS file (and your custom CSS) in your application's entry point or update the webpack entry, otherwise Tailwind’s utilities won’t be included in the bundle.
  • Add a tailwind.config.js with appropriate content paths so Tailwind can tree-shake unused styles and pick up your templates/components for production builds.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Make sure you import the new Tailwind CSS file (and your custom CSS) in your application's entry point or update the webpack entry, otherwise Tailwind’s utilities won’t be included in the bundle.
- Add a tailwind.config.js with appropriate content paths so Tailwind can tree-shake unused styles and pick up your templates/components for production builds.

## Individual Comments

### Comment 1
<location> `render_build.sh:31` </location>
<code_context>
-    npx @sentry/cli --auth-token=$SENTRY_API_KEY releases --org=$SENTRY_ORG --project=$SENTRY_PROJECT_NAME files $RENDER_GIT_COMMIT upload-sourcemaps ./frontend/webpack_bundles/ --url-prefix "~/static/webpack_bundles/" --rewrite
-    rm ./frontend/webpack_bundles/*.js.map
+if [[ -n "${SENTRY_API_KEY:-}" && -n "${SENTRY_ORG:-}" && -n "${SENTRY_PROJECT_NAME:-}" && -n "${RENDER_GIT_COMMIT:-}" ]]; then
+  npx @sentry/cli --auth-token="${SENTRY_API_KEY}" releases --org="${SENTRY_ORG}" --project="${SENTRY_PROJECT_NAME}" files "${RENDER_GIT_COMMIT}" upload-sourcemaps "./frontend/webpack_bundles/" --url-prefix "~/static/webpack_bundles/" --rewrite
+  rm -f ./frontend/webpack_bundles/*.js.map
 fi
</code_context>

<issue_to_address>
Quoting variables in CLI arguments prevents word splitting and globbing issues.

Quoting variables in the command ensures correct handling of values with spaces or special characters, making the script more reliable.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
if [[ -n "${SENTRY_API_KEY:-}" && -n "${SENTRY_ORG:-}" && -n "${SENTRY_PROJECT_NAME:-}" && -n "${RENDER_GIT_COMMIT:-}" ]]; then
  npx @sentry/cli --auth-token="${SENTRY_API_KEY}" releases --org="${SENTRY_ORG}" --project="${SENTRY_PROJECT_NAME}" files "${RENDER_GIT_COMMIT}" upload-sourcemaps "./frontend/webpack_bundles/" --url-prefix "~/static/webpack_bundles/" --rewrite
  rm -f ./frontend/webpack_bundles/*.js.map
fi
=======
if [[ -n "${SENTRY_API_KEY:-}" && -n "${SENTRY_ORG:-}" && -n "${SENTRY_PROJECT_NAME:-}" && -n "${RENDER_GIT_COMMIT:-}" ]]; then
  npx @sentry/cli --auth-token="${SENTRY_API_KEY}" releases --org="${SENTRY_ORG}" --project="${SENTRY_PROJECT_NAME}" files "${RENDER_GIT_COMMIT}" upload-sourcemaps "./frontend/webpack_bundles/" --url-prefix "~/static/webpack_bundles/" --rewrite
  rm -f "./frontend/webpack_bundles/"*.js.map
fi
>>>>>>> REPLACE

</suggested_fix>

### Comment 2
<location> `webpack.config.js:49` </location>
<code_context>
-            "css-loader",
-            // Compiles Sass to CSS
-            "sass-loader",
+            { loader: "css-loader", options: { importLoaders: 1 } },
+            // Tailwind v4 uses @tailwindcss/postcss (condigured in the postcss.config.mjs file)
+            "postcss-loader",
</code_context>

<issue_to_address>
Setting 'importLoaders: 1' ensures imported CSS is processed by postcss-loader.

This adjustment is required for proper handling of CSS imports with postcss plugins like Tailwind.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
            { loader: "css-loader", options: { importLoaders: 1 } },
            // Tailwind v4 uses @tailwindcss/postcss (condigured in the postcss.config.mjs file)
            "postcss-loader",
=======
            {
              loader: "css-loader",
              options: { importLoaders: 1 }
            },
            // Tailwind v4 uses @tailwindcss/postcss (configured in the postcss.config.mjs file)
            {
              loader: "postcss-loader"
            },
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@raisiqueira raisiqueira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good. Just left two questions.

@@ -4,7 +4,8 @@ import { createRoot } from "react-dom/client";

import App from "./App";

import "../sass/style.scss";
import "../css/tailwind.css";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why not merge these two styles into just one?

@import "tailwindcss";

#django-background {
    color: #092e20;
    font-size: 11pt;
    background-repeat: no-repeat;
    background-size: auto 200px;
    background-position: center;
    height: 300px;
    background-image: url('../assets/images/django-logo-positive.png');
}

#django-logo-wrapper {
    color: #092e20;
    & > img {
        width: 100px;
    }
    margin-bottom: 1em;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong reason. I can merge without any problems. The idea was to show that we can have custom styles in one place and Taiwind's customizations in another. What's your suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to merge them. Generally, on Tailwindcss environments, the customization is close to the components (CSS modules, or even inline class names).

For example, in a component like ⁠Button.jsx, I'd define custom styles directly in a CSS module or use Tailwind's ⁠@apply directive inline, keeping everything co-located. Otherwise, we can just use inline className="..."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, in general should be inline with className to follow Tailwind convetions
I think all those values could be inline styles with className using Tailwind utility classes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove bootstrap?
3 participants