Skip to content

Commit fb19921

Browse files
Wendellvthinkxie
authored andcommitted
build: fix compile style-script (#3331)
* build: fix compile style-script * docs: fix card docs * fix: use copying instead of generating * fix: typo
1 parent b4161cd commit fb19921

3 files changed

Lines changed: 4 additions & 9 deletions

File tree

components/card/doc/index.zh-CN.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ cols: 1
2222

2323
想要了解更多关于单独引入组件的内容,可以在[快速上手](/docs/getting-started/zh#单独引入某个组件)页面进行查看。
2424

25-
```ts
2625
```ts
2726
import { NzCardModule } from 'ng-zorro-antd';
2827
```
29-
```
3028

3129
### nz-card
3230

components/components.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@import "./icon/style/entry.less";
12
@import "./affix/style/entry.less";
23
@import "./alert/style/entry.less";
34
@import "./anchor/style/entry.less";

scripts/build/compile-styles.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,9 @@ const sourcePath = path.resolve(__dirname, '../../components');
3737
const targetPath = path.resolve(__dirname, '../../publish');
3838
const componentFolders = fs.readdirSync(targetPath);
3939

40-
// Export each component's style in `component.less` and copy it to the target dir.
41-
let componentsLessContent = '';
42-
4340
componentFolders.forEach(dir => {
4441
if (fs.existsSync(`${sourcePath}/${dir}/style/index.less`)) {
4542
// Copy style files for each component.
46-
componentsLessContent += `@import "./${path.posix.join(dir, 'style', 'index.less')}";\n`;
4743
fs.copySync(`${sourcePath}/${dir}/style`, `${targetPath}/${dir}/style`);
4844

4945
// Compile less files to CSS and delete the `entry.less` file.
@@ -69,13 +65,13 @@ componentFolders.forEach(dir => {
6965

7066
// Copy concentrated less files.
7167
fs.copySync(path.resolve(sourcePath, 'style'), path.resolve(targetPath, 'style'));
72-
fs.writeFileSync(`${targetPath}/components.less`, componentsLessContent);
68+
fs.writeFileSync(`${targetPath}/components.less`, fs.readFileSync(`${sourcePath}/components.less`));
7369
fs.writeFileSync(`${targetPath}/ng-zorro-antd.less`, fs.readFileSync(`${sourcePath}/ng-zorro-antd.less`));
7470

7571
// Compile concentrated less file to CSS file.
7672
const lessContent = `@import "${path.posix.join(targetPath, 'ng-zorro-antd.less')}";`;
77-
compileLess(lessContent, path.join(targetPath, 'ng-zorro-antd.css'), false);
78-
compileLess(lessContent, path.join(targetPath, 'ng-zorro-antd.min.css'), true);
73+
compileLess(lessContent, path.join(targetPath, 'ng-zorro-antd.css'), false).catch(e => console.log(e));
74+
compileLess(lessContent, path.join(targetPath, 'ng-zorro-antd.min.css'), true).catch(e => console.log(e));
7975

8076
// Compile css file that doesn't have component-specific styles.
8177
const cssIndexPath = path.join(sourcePath, 'style', 'entry.less');

0 commit comments

Comments
 (0)