Skip to content

CSS Module styles with vh fallback units are removed during build #1727

@micahjon

Description

@micahjon

What is the current behaviour?
When running preact build (but not preact watch), padding or margin selectors with vh fallback units are removed from CSS module styles. Oddly enough, they are preserved for height selectors (e.g. min-height).

Steps to Reproduce

  1. Create a new Preact CLI project and add the following CSS to the Home route:
/* style.css */
.home {
  width: 100%;
  border: 10px solid red;

  padding: 50px;

  padding-bottom: 20vh; /* <- will be removed */
  padding-bottom: 20dvh;

  margin-bottom: 20vh; /* <- will be removed */
  margin-bottom: 20dvh;

  min-height: 20vh; /* <- will be preserved */
  min-height: 20dvh;
}
  1. Run npm run dev and see the CSS styles correctly rendered in Chrome. The dvh units are ignored (only for iOS) and the vh fallback units are rendered instead.

image

  1. Run npm run build && npm run serve and refresh the page in Chrome. The dvh units are ignored and the vh fallback units are missing for the padding and margin styles, but preserved for min-height.

image

What is the expected behaviour?
vh units should not be removed from the CSS. It appears that some style de-duplication or minification is happening that doesn't understand that dvh and vh units can be used for padding and margins.

Thanks for your help with this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions