greengerong / rebirth

GreenGerong(破狼) blog with Angular4.
https://greengerong.github.io/rebirth
MIT License
356 stars 118 forks source link

创建component-cli的辅助工具 #7

Closed greengerong closed 7 years ago

greengerong commented 8 years ago

component大部分是一致的,可以尝试利用npm创建目录和文件结构(DRY):

1:命令行输入component文件名(以“-”风格)
2:生成文件包括:app下的component目录、[component name].component.ts、[component name].html、[component name].scss、 index.ts
3:文件内容:

index.ts:

export * from './[component name].component';

[component name].component.ts:

import { Component, Input, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
import {Article} from '../article-service';

@Component({
  selector: 'article-item',
  providers: [],
  directives: [],
  pipes: [],
  styles: [require('./article-item.scss')],
  template: require('./article-item.html')
})
export class [component name(驼峰命名)] {
    constructor() {

    }
}

[component name].html:

<div class="[component name](中划线分割)">
 [component name]
</div>

命令行文件组件生产,基于feature设计。

greengerong commented 8 years ago

等待angular-cli项目release,然后迁移到此工具

greengerong commented 7 years ago

Master brach changed to angular-cli version