Skip to content

Instantly share code, notes, and snippets.

@AvocadoVenom
Last active December 12, 2019 22:00
Show Gist options
  • Select an option

  • Save AvocadoVenom/557c7dd4d3e95d20f0227f576613b90c to your computer and use it in GitHub Desktop.

Select an option

Save AvocadoVenom/557c7dd4d3e95d20f0227f576613b90c to your computer and use it in GitHub Desktop.
Angular schematics : creating main module from template
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ComponentsModule } from './components/components.module';
@NgModule({
declarations: [],
imports: [CommonModule, ComponentsModule]
})
export class <%= classify(name) %>Module { }
function createMainModuleFileDefinition(options: ModuleOptions): Rule {
const templateSource = apply(url('./files'), [
filter(path => path.endsWith('__name@dasherize__.module.ts.template')),
applyTemplates({
...strings,
...options
}),
renameTemplateFiles(),
move(normalize(`${options.name}/`))
]);
return mergeWith(templateSource);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment