-
Notifications
You must be signed in to change notification settings - Fork 450
Description
Description
SVG minification is conditionally applied based on the NODE_ENV environment variable.
If NODE_ENV is not explicitly set to "production", SVG files will not be optimized, even during builds intended for deployment.
Code concerned
const IS_PRODUCTION_BUILD = process.env.NODE_ENV === 'production';
const shouldMinifySVG = function (file) {
return IS_PRODUCTION_BUILD && file.path.match(/.svg$/);
};
Problems
NODE_ENV may be undefined or incorrectly set
Production builds may ship unminified SVG assets
Behavior is implicit and not obvious to contributors
Asset size optimization depends on external environment configuration
Expected Behavior
Production builds should reliably minify SVGs
Build behavior should be explicit and predictable
Developers should not need to guess environment requirements
Suggested Fix
Option 1: Provide a default fallback
const IS_PRODUCTION_BUILD =
process.env.NODE_ENV === 'production' || process.env.CI === 'true';
Option 2: Expose an explicit build flag
const IS_PRODUCTION_BUILD = process.env.MINIFY_ASSETS === 'true';
Option 3: Document the requirement clearly in the project README.
Impact
Smaller production bundles
More predictable build behavior
Easier onboarding for new contributors
Reduced risk of shipping unoptimized assets