Skip to content

Commit

Permalink
build: fix compile style-script (#3331)
Browse files Browse the repository at this point in the history
* build: fix compile style-script

* docs: fix card docs

* fix: use copying instead of generating

* fix: typo
  • Loading branch information
Wendell authored and vthinkxie committed Apr 22, 2019
1 parent b4161cd commit fb19921
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 0 additions & 2 deletions components/card/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ cols: 1

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

```ts
```ts
import { NzCardModule } from 'ng-zorro-antd';
```
```

### nz-card

Expand Down
1 change: 1 addition & 0 deletions components/components.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import "./icon/style/entry.less";
@import "./affix/style/entry.less";
@import "./alert/style/entry.less";
@import "./anchor/style/entry.less";
Expand Down
10 changes: 3 additions & 7 deletions scripts/build/compile-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@ const sourcePath = path.resolve(__dirname, '../../components');
const targetPath = path.resolve(__dirname, '../../publish');
const componentFolders = fs.readdirSync(targetPath);

// Export each component's style in `component.less` and copy it to the target dir.
let componentsLessContent = '';

componentFolders.forEach(dir => {
if (fs.existsSync(`${sourcePath}/${dir}/style/index.less`)) {
// Copy style files for each component.
componentsLessContent += `@import "./${path.posix.join(dir, 'style', 'index.less')}";\n`;
fs.copySync(`${sourcePath}/${dir}/style`, `${targetPath}/${dir}/style`);

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

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

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

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

0 comments on commit fb19921

Please sign in to comment.