Summary: IItemTransform
is not triggered when a minified file already exists in the same directory as the original (non-minified) file.
Issue Description
The problem arises due to CSS relative image references, impacting both JavaScript and CSS files when using IItemTransform
.
Scenario:
- Developing with Visual Studio and Web Essentials addin for LESS file support
- Automatically minifying LESS files on save using Web Essentials
- Employing bundling and minification techniques in the project
- Using
CssRewriteUrlTransform
to convert CSS URLs to absolute paths for proper functionality after bundling multiple CSS files
Despite following these steps, the issue persists.
Identified Problem
Bundling and minification processes prioritize performance efficiency by avoiding redundant processing. This means that if a minified version of a file exists in the same directory as the original, it skips its own minification process and serves the existing file instead.
However, the transforms are not applied to these preexisting minified files, resulting in broken relative URLs within the bundle.
Solutions
- Use absolute paths in LESS files at all times
- Disable automatic file minification in Web Essentials settings
- Reference minified files directly when defining bundles to ensure proper transformation and minification both occur
Given the development setup and configuration, this behavior appears to be a bug. Processing existing minified files through transforms before caching would prevent such issues from occurring.
Inquiry
Is there a way to prompt bundling and minification to either:
- Avoid utilizing existing minified versions
- Apply transformations to existing minified versions