Skip to content

Conversation

@dermatz
Copy link
Collaborator

@dermatz dermatz commented Jan 17, 2026

Automatic Static File Cleaning in Developer Mode

Problem

In developer mode, Magento generates static files on-demand which can conflict with theme builder outputs. This leads to inconsistent styling and cached assets that don't reflect the latest theme changes.

Solution

Implemented automatic cleaning of theme-specific static files before build/watch operations when running in developer mode.

Key Changes:

  • ThemeCleaner Service: Centralized service for all theme cleaning operations (eliminates code duplication)
  • StaticContentCleaner Service: Detects developer mode and automatically cleans:
    • pub/static/frontend/{Vendor}/{theme}/
    • var/view_preprocessed/css/frontend/{Vendor}/{theme}/
    • var/view_preprocessed/source/frontend/{Vendor}/{theme}/
  • Builder Integration: All three builders (HyvaThemes, MagentoStandard, TailwindCSS) now use StaticContentCleaner
  • CleanCommand Refactoring: Refactored to use ThemeCleaner service (~210 lines of duplicate code removed)

Behavior:

  • ✅ Automatic cleaning only in developer mode
  • ✅ Silent in normal mode, verbose output with -v flag
  • ✅ Works for both build and watch commands
  • ✅ Manual cleaning still available via mageforge:theme:clean

@dermatz dermatz force-pushed the clean-before-build branch from 7f67171 to f4cd1a6 Compare January 17, 2026 12:09
@dermatz dermatz merged commit 80a6abf into main Jan 17, 2026
8 checks passed
@dermatz dermatz deleted the clean-before-build branch January 17, 2026 12:12
@github-actions github-actions bot mentioned this pull request Jan 17, 2026
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