question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Customizing default template

See original GitHub issue

Hey guys!

We would like to use all the power provided by create-react-app every time we start with a new project. As we always add few extra libraries after the app is created like react-router, redux, classnames and use a slightly different project structure to the provided by the default template, I was wondering if there is a recommended way of doing this repetitive work.

Here is what I tried so far:

  1. Fork of react-scripts and modify the default template With this solution is possible to modify the generated app structure. However, adding new dependencies is not quite simple. It takes adding a .template.dependencies.json and modifying the scripts/init.js so it installs the additional dependencies if present even when a custom template is not provided via --internal-testing-template and avoid installing react and react-dom when previously installed. I’m wondering if this could be a feature request itself.

    A downside I see with this approach is it takes maintaining your own version of react-scripts even when you don’t need to modify the react-scripts dependencies itself but the template’s dependencies.

  2. CRAFT. React Create App From Template This is a very interesting concept. This command line utility allows you to use your own template when creating a new app. The problem is it doesn’t really create a new app but basically copies a repository with a previously created react app then applies some changes to the output, as far as I could see. This is far from being ideal since when I’m creating a new app, I would prefer using the most recent version of react-scripts as possible rather on rely on the one installed in the template, which may be outdated.

This may be an advanced use case and not sure if it is out of the core ideas for this awesome project but it seems create-react-app already contains most of the things needed to support something like this:

create-react-app MyApp --template <url-to-template>

Does anyone know what is the general recommendation from the community to deal with this case?

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
marcopegcommented, Oct 15, 2018

Hello everyone, I was digging the same issue as I’m creating a small fork (as suggested into the official docs) to support some webpack extensions (like in react-app-rewired) and adding some custom templates.

I found out that --internal-testing-template is currently supported and will try to fetch a template folder from the cwd.

It works decently enough for me, but I’ve tweaked a little bit the init.js so to be able to host more basic templates in my own version of react-scripts.

I hope this flag that seems so experimental will one day become just --template as you all suggest!

1reaction
corysimmonscommented, Oct 10, 2018

https://github.com/facebook/create-react-app/issues/2960#issuecomment-356108258

This logic can be applied to CRA itself, right?

Lots of boilerplate generating CLI’s have a --template flag.

They make the mistake of making those templates 3rd party, but if CRA team would maintain a few variants then --template could be handy.

Very specifically: I hate having to delete all the junk in a CRA app (yes I fire up a lot of CRA apps just to test misc stacks) and would love a --template=bare or just --bare flag. I really don’t care about the rest.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the Normal template (Normal.dotm ) - Microsoft Support
Change the Normal template (Normal.dotm ) · On the File tab, click Open. · Go to C:\Users\user name\AppData\Roaming\Microsoft\Templates. · Open the Normal template...
Read more >
Changing the Default Template in Word
First you'll need to follow our "Show Hidden Files and Folders" instructions so you can access the Normal.dotm template file. 2. With Word...
Read more >
How to create a default page template - Full Site Editing
When a user creates a new custom page template via the block editor, -a page specifically created for a single page, WordPress loads...
Read more >
How to Customize the Normal Template in Microsoft Office
In Word, go to File > Open > Browse > locate Templates > select Normal.dot or Normal.dotm > make desired changes > Save....
Read more >
Customize Default Template • Joomla Tutorial - FastComet
How to customize the default template in Joomla · Click on the name of your default template. · Select the Advanced tab. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found