-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customizing default template #2960
Comments
Here's a third alternative that does all that you want without too much extra work: Write a script that works on top of #!/usr/bin/env bash
create-react-app $1
cd $1
yarn add react-router redux classnames
# use mv and mkdir commands to get desired project structure You can use it like this: ./create-custom-react-app.sh my-new-app |
@fcaldera I create a |
Thanks @GAumala. It looks like a good approach. Our needs however demanded a more flexible and maintainable solution since we wanted to share this across teams and every team may have different needs on dependencies and project structure. In simpler scenarios it can definitely work. |
@likun7981 it seems we ended up like building the same thing. You can see ours here: https://github.com/fcaldera/craft. This is pretty much a WIP so please disregard our lack of documentation. I like several things you did down there, specially the support for local templates and the use of the hidden option of create-react-app which simplifies everything. Not sure how much we should rely on that hidden feature but it was definitely a smart move. Thanks for sharing! |
I think this is an excellent idea, and should be added as a built-in option to the CRA CLI tool. This would possibly help address complaints that CRA doesn't deal with app setup at all. This way, the Redux docs could tell people to use I'm going to cheat a bit and tag @gaearon and @Timer to see if I can bring this to their attention. |
I'd be willing to implement this if it's something the CRA team would like to include. I personally think it would be useful. I just looked at the code and it seems like everything is in place for this already. There's even a super secret option that will let you use it:
It would be very easy to make this an officially supported option so I'm guessing there's a reason it's not exposed. I'd love to know what that is though. |
Can you explain how this is different from just |
CRA moves fast and it is good you can always use the most recent version of Imagine if we had to remember updating |
Doesn't semver sort of give you that? You can set There's no guarantee your template will be compatible with future major versions. So this is a problem in either case. |
That's an interesting point. It will take some manual steps like setting a specific version for react-scripts in the cloned app and changing the git origin but I can see value on it. Don't you think it would be nice that we can also use the most recent version of As I envision this, a custom template doesn't necessarily need to play as a full replacement of the default template but as a complement. That said, I may only need to include some extras files and folders to my template and then gets everything merged with the default template. It would mean I don't need to include and maintaining a |
Having this option officially supported would be useful for people who want to extend CRA (something like this. Just having a repository to be used as a initial app template is not as useful as having a package that extends CRA as a dependency of your project. Having a package allow us to update script and push this updates via package update, allowing the user to get the new code just by updating the version of the package. Doing this with a template repository is not as practical. |
This logic can be applied to CRA itself, right? Lots of boilerplate generating CLI's have a They make the mistake of making those templates 3rd party, but if CRA team would maintain a few variants then 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 |
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 It works decently enough for me, but I've tweaked a little bit the I hope this flag that seems so experimental will one day become just |
Can this be closed now the |
Whoa I need to read release blog posts. :O Nice! Thank you CRA Team! <3 |
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:
Fork of
react-scripts
and modify the default templateWith 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 thescripts/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.
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!
The text was updated successfully, but these errors were encountered: