A script to create a template component
Screen.Recording.2024-05-25.at.14.10.03.mov
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;
};