Static files deployment strategies
When deploying static view files, you can choose one of the three available strategies. Each of them provides optimal deployment results for different use cases:
- Standard: the regular deployment process.
- Quick (default): minimizes the time required for deployment when files for more than one locale are deployed.
- Compact: minimizes the space taken by the published view files.
The following sections describe the implementation details and features of each strategy.
When the Standard strategy is used, all static view files for all packages are deployed, that is, processed by
For more information, see Deploy static view files.
The quick strategy performs the following actions:
- For each theme, one arbitrary locale is chosen and all files for this locale are deployed, like in the standard strategy.
- For all other locales of the theme:
- Files that override the deployed locale are defined and deployed.
- All other files are considered similar for all locales, and are copied from the deployed locale.
By similar, we mean files that are independent of the locale, theme, or area. These files might include CSS, images, and fonts.
This approach minimizes the deployment time required for multiple locales although a lot of files are duplicated.
The compact strategy avoids file duplication by storing similar files in
For the most optimized result, three scopes for possible similarity are allocated: area, theme, and locale.
base subdirectories are created for all combinations of these scopes.
The files are deployed to these subdirectories according to the following patterns.
Files specific for a particular area, theme, and locale
||Files similar for all locales of a particular theme of a particular area.|
||Files specific for a particular area and locale, but similar for all themes.|
Files specific for a particular area, but similar for all themes and locales.
Files similar for all areas and themes, but specific to a particular locale.
||Similar for all areas, themes and locales.|
Mapping deployed files
The approach to deployment used in the compact strategy means that files are inherited from base themes and locales. This inheritance relations are stored in the map files for each combination of area, theme and locale. There are separate map files for PHP and JS:
map.php is used by
Magento\Framework\View\Asset\Repository to build correct URLs.
requirejs-map.js is used by the
baseUrlResolver plugin for RequireJS.
Tips for extension developers
To build URLs to static view files, use
Do not use URL concatenations to avoid problems with static files being not found and not displayed during page rendering.