arminbro / generate-react-cli

A simple React CLI to generate components instantly and more.

Home Page:https://www.npmjs.com/package/generate-react-cli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for custom extension like .mdx for stories instead of defaulted to .tsx

Anima-t3d opened this issue · comments

Is your feature request related to a problem? Please describe.
I am using .mdx format for storybook stories, but config will generate file with .tsx extension for my stories.

Describe the solution you'd like
If custom template file extension is not .js, do not convert to .tsx but use existing file extension instead.

Describe alternatives you've considered
Alternatively is to manually rename, but defeats the benefit of using the cli.

Additional context
Related to Support for .jsx extension but different use case.

I can potentially do this and make a PR.

Hi @Anima-t3d. Thanks for the feedback. Sure this makes sense. I'll take care of this issue in the next release.

@Anima-t3d I apologize for the late commit. I've been busy these past couple of months. I just had some downtime to take care of your request.

The new release of v5.1.0 now supports custom extensions via custom templates.

You should now be able to declare a custom story template with its own extension within your generate-react-cli.json config file.

Something like this:

{
  "usesTypeScript": false,
  "usesCssModule": true,
  "cssPreprocessor": "scss",
  "testLibrary": "Testing Library",
  "component": {
    "default": {
      "customTemplates": {
        "story": "templates/component/story.mdx"
      },
      "path": "src/components",
      "withStyle": true,
      "withTest": true,
      "withStory": true,
      "withLazy": false
    }
  }
}

Let me know if you run into any other problems. Thanks again for the request.