Migrate Less Applications with Codemod#
To facilitate the unified upgrade of business applications, we provide a one-click migration codemod from less to antd-style.
Usage#
Simply execute the following command in the project root directory:
npx @chenshuai2144/less2cssinjs less2js -i src
Where src is the project directory.
![]()
Transformation Logic#
In this codemod, we will perform the following transformations:
For less files:
- Create a new
[file].style.tsfile, wherefileis the name of the less file. - Convert the styles in the less file to the css object syntax in antd-style.
- Flatten the nested syntax in less to a single level.
- Automatically replace less variables with antd-style tokens.
For ts files:
- Replace import less with
import useStyles from '[file].style'. - Add
const { style } = useStyles().
Notes#
TBD