Skip to content

Commit 5b269cb

Browse files
committed
docs: update customize-theme
1 parent 4b8bdc8 commit 5b269cb

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

docs/vue/customize-theme.en-US.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,22 @@ Specify the `theme` property in the `package.json` or `.webpackrc` file, whose v
2828
"primary-color": "#1DA57A",
2929
},
3030
```
31+
you can write a webpack config about [less-loader modifyVars](https://github.com/webpack/less-loader#less-options) like [atool-build](https://github.com/ant-tool/atool-build/blob/a4b3e3eec4ffc09b0e2352d7f9d279c4c28fdb99/src/getWebpackCommonConfig.js#L131-L138) does.
32+
33+
Note:
34+
35+
- Importing styles from less files is necessary.
36+
- If you import styles by specifying the `style` option of [babel-plugin-import](https://github.com/ant-design/babel-plugin-import), change it from `'css'` to `true`, which will import the `less` version of antd.
37+
- If you import styles from `'vue-antd-ui/dist/antd.css'`, change it to `vue-antd-ui/dist/antd.less`.
38+
- If you want to override `@icon-url`, the value must be contained in quotes like `"@icon-url": "'your-icon-font-path'"`.
3139

3240
### 2) Overriding Less variables (alternative way)
3341

3442
Override variables via less definition files.
3543

3644
Create a standalone less file like the one below, and import it in your project.
3745

38-
```css
46+
```less
3947
@import "~vue-antd-ui/dist/antd.less"; // import official less entry file
4048
@import "your-theme-file.less"; // override variables here
4149
```

docs/vue/customize-theme.zh-CN.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,23 @@ antd 的样式使用了 [Less](http://lesscss.org/) 作为开发语言,并定
3030
"primary-color": "#1DA57A",
3131
},
3232
```
33+
定义 `theme` 属性时,需要配合使用`less-loader``modifyVars` 配置来覆盖原来的样式变量。
34+
可以参考 [atool-build 中 less-loader 的 webpack 相关配置](https://github.com/ant-tool/atool-build/blob/a4b3e3eec4ffc09b0e2352d7f9d279c4c28fdb99/src/getWebpackCommonConfig.js#L131-L138)
35+
36+
注意:
37+
38+
- 样式必须加载 less 格式。
39+
- 如果你在使用 [babel-plugin-import](https://github.com/ant-design/babel-plugin-import)`style` 配置来引入样式,需要将配置值从 `'css'` 改为 `true`,这样会引入 less 文件。
40+
- 如果你是通过 `'vue-antd-ui/dist/antd.css'` 引入样式的,改为 `vue-antd-ui/dist/antd.less`
41+
- 如果要覆盖 `@icon-url` 变量,内容需要包括引号 `"@icon-url": "'your-icon-font-path'"`
3342

3443
### 2) less
3544

3645
用 less 文件进行变量覆盖。
3746

3847
建立一个单独的 `less` 文件如下,再引入这个文件。
3948

40-
```css
49+
```less
4150
@import "~vue-antd-ui/dist/antd.less"; // 引入官方提供的 less 样式入口文件
4251
@import "your-theme-file.less"; // 用于覆盖上面定义的变量
4352
```

0 commit comments

Comments
 (0)