A script to create a template component
npm install un-cc@latest -D
import { createComponent } from 'un-cc';
createComponent({
staticComponentDir: 'src',
componentDirectoryStr: ['components'],
templatesDir: 'scripts/templates',
transform(content, componentName) {
return content.replaceAll('COMPONENT_NAME', 'TestComponent');
},
});
type CreateComponentOptions = {
staticComponentDir: string;
componentDirectoryStr: string[];
templatesDir: string;
transform?: (content: string, componentName: string) => string;
transformFileName?: (filename: string, componentName: string) => string;
transformExecFile?: (componentName: string) => string;
};