airbnb / goji-js

React ❤️ Mini Program
https://goji.js.org
MIT License
223 stars 26 forks source link

Some `calc` CSS usages fails on Toutiao #159

Closed malash closed 2 years ago

malash commented 2 years ago

Description

According to official document the whitespace around * and / in a calc function can be ignored. But when using calc with rpx, some cases fail on Toutiao like calc(100rpx*10).

Cases Toutiao Others
calc(20rpx * 10)
calc(20rpx* 10)
calc(20rpx *10)
calc(20rpx*10)

Reproduct link

https://microapp.bytedance.com/ide/minicode/Nvx4ncd

Reproduct steps

Open the link in Toutiao dev tool.

Impact

Because GojiJS uses cssnano to minimize all CSS styles, the whitespaces are removed during Webpack build. It cause some CSS styles fail to run Toutiao.

Temporary solution

  1. Change the options of cssnano to skip this kind of minimization.
  2. Implement a new PostCSS plugin to add whitespaces back.

Platforms

malash commented 2 years ago

Official forum https://forum.microapp.bytedance.com/mini-app/posts/625655d3806b24d2e4dbe214