[Support Guide] How can I optimize my Netlify build time?

@brianjychan, I @mentioned the wrong person and wanted to be sure you saw my reply to you above.

(Thanks for pointing out my typo, @brycewray.) :+1:

2 Likes

@luke thanks for the pointer, with that and Create build plugins I figured out how to do it!

Suggestions
On Build Plugins, I think it would help to move the yellow “Current Build Image required” warning to the top of the page; I didn’t see it for awhile since I was doing file-based configuration.

Questions
If you have a moment, I have two unresolved problems resulting from me caching my React App dependencies instead of a fresh npm install of node_modules. These questions might be out of scope, but I wonder if you might know anything about them:

1
I saw that the create-react-app command of react-scripts build didn’t work after cache restore (using utils.cache.restore('node_modules'))

Later I found it was because node_modules/.bin/ was not cached. This caused node_modules/.bin/react-scripts to be missing.

I resolved this by manually caching the node_modules/.bin; is this an antipattern?

2
After the above, I found that react-scripts build would now run, but threw the below error.

It appears to be unable to resolve node_modules/react-scripts/scripts/build.js/ when running:
node_modules/.bin/react-scripts

Do you know why this might be?

I ended up deciding to use the executable at
node_modules/react-scripts/bin/react_scripts.js
instead, and not caching node_modules/.bin.

For more context (and if anyone else sees this), my plugin code is here:

Let me know if you see anything amiss at a glance, I doubt I have done this in the best way

Thanks for your time!

hey @koudai0024, as mentioned above, you can actually change this yourself now:

https://answers.netlify.com/t/support-guide-how-can-i-optimize-my-netlify-build-time/3907/102

Hi @luke this is my first time write post here. Thank you Netlify for providing very great support through this forum.

I don’t know wether my question will fit into this thread or not. But here is my question, If we use Netlify CLI and build our project locally then deploy it using Netlify CLI as well. Is that count in build minutes?

hi there, you might find this interesting:

1 Like

@perry Thank you! Could you please confirm it’s all fine though? We have just tested and it’s still breaking around 17min.

@perry It’s working now, don’t worry :pray:t4:

1 Like

Thank you for confirming, @anquadros !

1 Like

Hey there, @sebseb :wave:

Thanks for sharing. I recommend you take a look at this Build Performance Pro Tips and Debugging Site Builds.

If you are still having issues after following those steps, please respond with:

  • Your site name and site ID (we need these to dig in further on our end!)
  • The issue you are encountering and what you are aiming to resolve
  • the steps you have already tried / guides you have already read (this will help avoid repeat suggestions!)

In your Netlify site UI, navigate to Site settings > Build & deploy > Continuous deployment > Build hooks. Now, whenever new content is published in your CMS, it will send a POST request to the build hook URL and Netlify will rebuild your site as a result

Hi @seewqi :wave:t6: ,

Welcome to the forums! Thanks for stopping by. (: This is helpful thank you for sharing this with the community.

  1. If you know exactly when you want to build and are willing to trigger it yourself through our UI or via an incoming webhook, our Support team can enable a flag for your site(s) to skip all automatic builds from git, and use only the ones from your own custom webhooks which will still pull your code from git and perform a normal build.

I like the option of “trigger it yourself through our UI” - is this really possible and where does this trigger in the UI sit? The reason I’m asking is coz its not fully explained here, only the bit about webhooks is explained - “use only the ones from your own custom webhooks”

Hi, @zehawki. The button to trigger deploys is found under the deploy tab for each site. Here is a screenshot to clarify:

Ohk, got it. Its the same button, I was somehow thinking something new would come in.

So then may I request that the flag be set for all my site(s) to skip all automatic builds from git. (OR should I do this via email support)?

You can let us know the account slur or ID and we can make the change.

So I notice that manually triggering via UI does not have a deploy message. Is it possible to set something, or to have it pick up the latest comment from Git head?

Nope. We only use the commit message when we build from a specific commit at the time of the commit.