Skip to content

fix(templates): loading bootstrap files from static, discarding unused files from CDN #276 #277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Grosskopf
Copy link

@Grosskopf Grosskopf commented Apr 26, 2025

Hi @fsbraun if you want, this PR would address the problems mentioned at #276

I have

  • Replaced the bootstrap js and css files that were loaded from a cdn in the bootstrap base template with files loaded from static
  • Made sure that the bootstrap js and css files are updated by gulp
  • Updated the documentation of djangocms-frontend to no longer mention that those files are loaded from a cdn
  • Removed the css file from the tailwind base template, as you mentioned we assume the customers to provide their own css files for tailwind
  • removed the card-group.js file as it is not used anywhere and mentioned an image loaded from an external server

Summary by Sourcery

Load Bootstrap assets from local static files instead of CDN and remove unused assets.

Enhancements:

  • Load Bootstrap CSS and JS from local static files in the Bootstrap 5 base template.
  • Remove unused CDN script from the Tailwind base template.
  • Remove unused card-group.js component file.

Build:

  • Configure Webpack to bundle Bootstrap JavaScript.
  • Add Bootstrap SCSS source file for local CSS compilation.

Documentation:

  • Update documentation to remove mentions of loading Bootstrap assets from CDN.

Copy link
Contributor

sourcery-ai bot commented Apr 26, 2025

Reviewer's Guide by Sourcery

This pull request updates the Bootstrap base template to load CSS and JavaScript files from local static files instead of a CDN. It also removes unused files and updates the documentation to reflect these changes.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Load Bootstrap CSS and JS from static files instead of CDN.
  • Update Bootstrap base template to use static files.
  • Add bootstrap.js to webpack configuration.
  • Include generated bootstrap CSS and JS files.
djangocms_frontend/templates/bootstrap5/base.html
private/js/webpack.config.js
djangocms_frontend/static/djangocms_frontend/css/bootstrap.css
djangocms_frontend/static/djangocms_frontend/js/bundle.bootstrap.js
private/js/bootstrap.js
Remove unused Tailwind CSS CDN link.
  • Remove Tailwind CSS script tag from tailwind base template.
djangocms_frontend/templates/tailwind/base.html
Remove unused card-group.js file.
  • Delete the card-group.js file.
private/js/components/card-group.js
Update documentation regarding Bootstrap asset loading.
  • Modify documentation to remove mention of CDN for Bootstrap files.
docs/source/tutorial/builtin_components.rst

Possibly linked issues


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
Contributor

@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 @Grosskopf - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Avoid committing large generated static files like bootstrap.css and bundle.bootstrap.js; generate them via the build process instead.
  • The empty private/js/bootstrap.js webpack entry seems redundant or confusing given the presence of the generated bundle.bootstrap.js.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@Grosskopf Grosskopf changed the title fix(templates) loading bootstrap files from static, discarding unused files from CDN #276 fix(templates): loading bootstrap files from static, discarding unused files from CDN #276 Apr 26, 2025
Copy link

codecov bot commented Apr 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.68%. Comparing base (434ec8a) to head (3829e1e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #277   +/-   ##
=======================================
  Coverage   88.68%   88.68%           
=======================================
  Files         124      124           
  Lines        3366     3366           
  Branches      283      283           
=======================================
  Hits         2985     2985           
  Misses        264      264           
  Partials      117      117           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Grosskopf
Copy link
Author

after a lot of confusion about webpack I have decided that this is the best I can do, I have added copy-webpack-plugin as a npm dependency to allow gulp to copy the js file from one folder to another, this does not minimize the js file but I'm not good enough with webpack to figure out how to get this to work with minimization :)

@@ -1,7 +1,8 @@
const argv = require('minimist')(process.argv.slice(2));
const plugins = [];
const webpack = require('webpack');
const path = require('path');
const path = require('path');1
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const path = require('path');1
const path = require('path');

I assume the 1 is a typo here?

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

Successfully merging this pull request may close these issues.

2 participants