Skip to content

hunghg255/un-cc

Repository files navigation

logo

A script to create a template component

NPM Version NPM Downloads Minizip Contributors License

Demo

Screen.Recording.2024-05-25.at.14.10.03.mov

Get started

npm install un-cc@latest -D

Usage

import { createComponent } from 'un-cc';

createComponent({
  staticComponentDir: 'src',
  componentDirectoryStr: ['components'],
  templatesDir: 'scripts/templates',

  transform(content, componentName) {
    return content.replaceAll('COMPONENT_NAME', 'TestComponent');
  },
});

API

type CreateComponentOptions = {
  staticComponentDir: string;
  componentDirectoryStr: string[];
  templatesDir: string;
  transform?: (content: string, componentName: string) => string;
  transformFileName?: (filename: string, componentName: string) => string;
  transformExecFile?: (componentName: string) => string;
};