mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 14:13:37 +08:00
📝 beautify code style in documentation (#14457)
This commit is contained in:
parent
4e116962f2
commit
b87261673a
@ -136,16 +136,20 @@ module.exports = function override(config, env) {
|
||||
$ yarn add babel-plugin-import
|
||||
```
|
||||
|
||||
```
|
||||
const { override, fixBabelImports } = require('customize-cra')
|
||||
```diff
|
||||
+ const { override, fixBabelImports } = require('customize-cra');
|
||||
|
||||
module.exports = override(
|
||||
fixBabelImports('import', {
|
||||
libraryName: 'antd',
|
||||
libraryDirectory: 'es',
|
||||
style: 'css'
|
||||
})
|
||||
)
|
||||
- module.exports = function override(config, env) {
|
||||
- // do stuff with the webpack config...
|
||||
- return config;
|
||||
- };
|
||||
+ module.exports = override(
|
||||
+ fixBabelImports('import', {
|
||||
+ libraryName: 'antd',
|
||||
+ libraryDirectory: 'es',
|
||||
+ style: 'css',
|
||||
+ }),
|
||||
+ );
|
||||
```
|
||||
|
||||
Remove the `@import '~antd/dist/antd.css';` statement added before because `babel-plugin-import` will import styles and import components like below:
|
||||
@ -181,20 +185,21 @@ $ yarn add less
|
||||
$ yarn add --dev less-loader
|
||||
```
|
||||
|
||||
```
|
||||
const { override, fixBabelImports, addLessLoader } = require('customize-cra')
|
||||
```diff
|
||||
- const { override, fixBabelImports } = require('customize-cra');
|
||||
+ const { override, fixBabelImports, addLessLoader } = require('customize-cra');
|
||||
|
||||
module.exports = override(
|
||||
fixBabelImports('import', {
|
||||
libraryName: 'antd',
|
||||
libraryDirectory: 'es',
|
||||
style: true
|
||||
}),
|
||||
addLessLoader({
|
||||
javascriptEnabled: true,
|
||||
modifyVars: { "@primary-color": "#1DA57A" }
|
||||
})
|
||||
)
|
||||
fixBabelImports('import', {
|
||||
libraryName: 'antd',
|
||||
libraryDirectory: 'es',
|
||||
style: true,
|
||||
}),
|
||||
+ addLessLoader({
|
||||
+ javascriptEnabled: true,
|
||||
+ modifyVars: { '@primary-color': '#1DA57A' },
|
||||
+ }),
|
||||
);
|
||||
```
|
||||
|
||||
We use `modifyVars` option of [less-loader](https://github.com/webpack/less-loader#less-options) here, you can see a green button rendered on the page after rebooting the start server.
|
||||
|
@ -133,16 +133,20 @@ module.exports = function override(config, env) {
|
||||
$ yarn add babel-plugin-import
|
||||
```
|
||||
|
||||
```
|
||||
const { override, fixBabelImports } = require('customize-cra')
|
||||
```diff
|
||||
+ const { override, fixBabelImports } = require('customize-cra');
|
||||
|
||||
module.exports = override(
|
||||
fixBabelImports('import', {
|
||||
libraryName: 'antd',
|
||||
libraryDirectory: 'es',
|
||||
style: 'css'
|
||||
})
|
||||
)
|
||||
- module.exports = function override(config, env) {
|
||||
- // do stuff with the webpack config...
|
||||
- return config;
|
||||
- };
|
||||
+ module.exports = override(
|
||||
+ fixBabelImports('import', {
|
||||
+ libraryName: 'antd',
|
||||
+ libraryDirectory: 'es',
|
||||
+ style: 'css',
|
||||
+ }),
|
||||
+ );
|
||||
```
|
||||
|
||||
然后移除前面在 `src/App.css` 里全量添加的 `@import '~antd/dist/antd.css';` 样式代码,并且按下面的格式引入模块。
|
||||
@ -178,20 +182,21 @@ $ yarn add less
|
||||
$ yarn add --dev less-loader
|
||||
```
|
||||
|
||||
```
|
||||
const { override, fixBabelImports, addLessLoader } = require('customize-cra')
|
||||
```diff
|
||||
- const { override, fixBabelImports } = require('customize-cra');
|
||||
+ const { override, fixBabelImports, addLessLoader } = require('customize-cra');
|
||||
|
||||
module.exports = override(
|
||||
fixBabelImports('import', {
|
||||
libraryName: 'antd',
|
||||
libraryDirectory: 'es',
|
||||
style: true
|
||||
}),
|
||||
addLessLoader({
|
||||
javascriptEnabled: true,
|
||||
modifyVars: { "@primary-color": "#1DA57A" }
|
||||
})
|
||||
)
|
||||
fixBabelImports('import', {
|
||||
libraryName: 'antd',
|
||||
libraryDirectory: 'es',
|
||||
style: true,
|
||||
}),
|
||||
+ addLessLoader({
|
||||
+ javascriptEnabled: true,
|
||||
+ modifyVars: { '@primary-color': '#1DA57A' },
|
||||
+ }),
|
||||
);
|
||||
```
|
||||
|
||||
这里利用了 [less-loader](https://github.com/webpack/less-loader#less-options) 的 `modifyVars` 来进行主题配置,
|
||||
|
Loading…
Reference in New Issue
Block a user