generate-react-cli icon indicating copy to clipboard operation
generate-react-cli copied to clipboard

provide a config file to the custom-template

Open hugo1o1 opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe. I mean, it helps a lot when you can add a custom template. But if it is possible to provide a config file to our custom templates, like a regular exp replace or to generate a comonent with more options

for example there are so many pages with the same layout, but diff in some details like a seach form with different fields , or table with unlike columns

hugo1o1 avatar Aug 11 '21 07:08 hugo1o1

I also need this feature for stories. We are using the atomic design pattern and need to be able to generate stories with

export default {
  title: '${folder}/TemplateName',
  component: TemplateName,
} as ComponentMeta<Component>;

for like 'atoms/Heading'.

For now I guess I'll use a node script to sed-replace some text after generation but, that's kinda what a generator does so it's a shame there's no custom parameters option. Thanks for considering it!

mosesoak avatar Sep 24 '21 22:09 mosesoak

Not sure if this is still an issue. But have you considered using different templates for this?

For Example

{
    ...
        "atom": {
            "path": "src/components/atoms",
            "withLazy": true,
            "withStory": true,
            "withStyle": true,
            "withTest": true,
            "withTypes": true,
            "withConfig": true,
            "customTemplates": {
                "component": "src/templates/atoms/TemplateName.tsx",
                "config": "src/templates/atoms/TemplateName.config.ts",
                "lazy": "src/templates/atoms/TemplateName.lazy.tsx",
                "story": "src/templates/atoms/TemplateName.stories.tsx",
                "style": "src/templates/atoms/TemplateName.module.css",
                "test": "src/templates/atoms/TemplateName.test.tsx",
                "types": "src/templates/atoms/TemplateName.types.ts"
            }
        },
        "atom-subtype1": {
            "path": "src/components/atoms",
            "withLazy": true,
            "withStory": true,
            "withStyle": true,
            "withTest": true,
            "withTypes": true,
            "withConfig": true,
            "customTemplates": {
                "component": "src/templates/atoms/subtype-1/TemplateName.tsx",
                "config": "src/templates/atoms/TemplateName.config.ts",
                "lazy": "src/templates/atoms/TemplateName.lazy.tsx",
                "story": "src/templates/atoms/TemplateName.stories.tsx",
                "style": "src/templates/atoms/TemplateName.module.css",
                "test": "src/templates/atoms/TemplateName.test.tsx",
                "types": "src/templates/atoms/TemplateName.types.ts"
            }
        },
        "molecule": {
            ...
        },
        "particle": {
            ...
        },
        // etc
        ...
}

Though - if @arminbro agrees - I could see a post processor option work here and I might be interested in submitting a PR for that.

TyIsI avatar Jul 29 '23 18:07 TyIsI