Skip to content
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

Not issue. Just some thought about CRA. #3190

Closed
raymondsze opened this issue Sep 26, 2017 · 6 comments
Closed

Not issue. Just some thought about CRA. #3190

raymondsze opened this issue Sep 26, 2017 · 6 comments

Comments

@raymondsze
Copy link

Is this a bug report?

No

I love create-react-app and I am using it in the company projects.
But usually the choice of create-react-app cannot fulfill all our requirements.

As we all know, eject is not a good option.
Yes, I can fork the create-react-app and customize the react-scripts. But I have to maintain the fork and keep track of all the updates.

Someone ended up using react-app-rewired. It allows us to change the default configuration provided by creact-react-app with limited scope. But the overrides config have to be along with my web application project. It is not good to share the same build tools with teammate who might also working on react web project.

I believe that the default configuration provided by create-react-app is a good reference. But I also believe there are no perfect configuration unless the user create their own.

What I wonder is "Is it possible to provide a tool that let user extends the react-scripts to create their own react-scripts (Not tweak along with their react project) ?".
Let say, I just need to create a bin folder, and require the tool, then I can obtain the webpack and jest configuration that create-react-app provided, then I can do something to tweak the configuration. Publish it and use at my own risk.

Here are some features I would like to have but missing in create-react-app.

  1. Server side rendering, I think ssr is very important especially the product is in china market, the search engine is not google, javascript is not understandable to those search engine. Pre-render is just a workaround but not good solution. Here what I did is to tweak the webpack config with same manner of react-app-rewired (change the target to 'node' and libraryTarget to 'commonjs2').

  2. PWA, the default option of create-react-app is using 'Cache-first' policy. But 90% of times we want 'Network-first' to make user get the latest update. 'Cache-first' policy also have problem that the 'index.html' is being cached. Here what I did is to create separate script which call the 'workbox-cli' to generate the service worker.

  3. GraphQL, now the .graphql or .gql extensions are not understandable to create-react-app. Here what I did is to tweak the webpack and jest config with same manner of react-app-rewired (add graphql-tag/loader, and add jest-transform-graphql).

As you can see, I only need small modification to achieve my purpose...

@icopp
Copy link

icopp commented Sep 26, 2017

Some of this might be affected by the plugin system currently in progress, though I don't think we've been given any idea when that will be done.

@miraage
Copy link

miraage commented Sep 26, 2017

I think people misunderstand create-react-app purpose.
AFAIK it was made for new React developers who should not spend their time understanding the underlying build tools.
Since you're experienced developer feel free to eject and modify on your own.

// EDIT

As you can see, I only need small modification to achieve my purpose...

Despite it might be a small change, think outside of the box. There are a lot of developers who really want a couple of small features being shipped into CRA. It's simply impossible. You can not build an ideal software that will fit everyones needs.

@raymondsze
Copy link
Author

Thanks for reply.

You can not build an ideal software that will fit everyone needs.

Yes I agree. But nowadays the react-scripts are bundled with webpack and jest configuration, it is not just configurations but also some scripts that we would like to enjoy.

I think it is quite hard nowadays to create another react-scripts without forking the whole create-react-app repository.

How about if having a tool that can be helpful to create another react-scripts easily with our customized configuration? Just a thought.

@miraage
Copy link

miraage commented Sep 26, 2017

You can make an eject, configure application in the way you need.
Then you can grab those configuration files and create smth like Yeoman generator for your future apps.

@Timer
Copy link
Contributor

Timer commented Sep 29, 2017

I'll close this as it's 3 requests in one, and we already have issues tracking all of these proposals.
I really appreciate you taking the time to write this up, however.

Unfortunately, I don't think we'll ever be a one-size-fits all tool.

Thanks again!

@Timer Timer closed this as completed Sep 29, 2017
@raymondsze
Copy link
Author

For people who interested, I created a library called 'create-react-scripts'.
That is what I expect the way we could extend from 'react-scripts'.
https://github.com/raymondsze/create-react-scripts

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants