hypothesis / hypothesis/h

SVG minification depends on NODE_ENV but is not clearly documented or enforced

Open
#10,024 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
3.2k
Forks
459
Avg merge
27d 1h
Merged PRs (30d)
1

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.