Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(): Fix Parse error on PX #76

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

chenyulun
Copy link

#75
PX unit support
postcss-pxtorem Can write PX without converting to REM, and browsers also support PX units

@@ -36,6 +36,7 @@
([0-9]+("."[0-9]*)?|"."[0-9]+)vmin\b return 'VMINS';
([0-9]+("."[0-9]*)?|"."[0-9]+)vmax\b return 'VMAXS';
([0-9]+("."[0-9]*)?|"."[0-9]+)\% return 'PERCENTAGE';
([0-9]+("."[0-9]*)?|"."[0-9]+)PX\b return 'PX';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have px as LENGTH above on line 13.

And looks like this fix will not work 10pX and 10Px. It is better to make lower case before sending to parser.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have enabled the plugin to convert PX to REM, and 50px to 1rem.

div{
  width: 50px; // 1rem
  width: calc(100% - 10PX); // calc(100% - 10PX)
  height: calc(10px - 10PX); // calc(0.2rem -10PX)
}

This CSS can be converted multiple times and needs to be uppercase at all times,and the browser supports PXPx

This issue also appeared in postcss-calc and they fixed it(7.0.4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants