2022-08-08 19:32:46 +08:00
|
|
|
# `@ice/style-import`
|
|
|
|
|
|
|
|
|
|
A transform function for automatic import style.
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
import transform from '@ice/style-import';
|
|
|
|
|
|
2023-10-12 11:40:28 +08:00
|
|
|
transform(`import { Button } from 'antd';
|
2022-08-08 19:32:46 +08:00
|
|
|
ReactDOM.render(<Button>xxxx</Button>);`, [{
|
|
|
|
|
libraryName: 'antd',
|
|
|
|
|
style: (importSpecifiers) =>
|
|
|
|
|
importSpecifiers.map(specifier =>
|
|
|
|
|
`import 'antd/es/${specifier}/style'`).join('\n'),
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
// the code will turn out as blew:
|
|
|
|
|
/*
|
|
|
|
|
import { Button } from 'Button';
|
|
|
|
|
import 'antd/es/Button/style';
|
|
|
|
|
ReactDOM.render(<Button>xxxx</Button>); */
|
2023-10-12 11:40:28 +08:00
|
|
|
```
|