In this lesson, you'll learn how to set up and prepare a project for deployment. The instructor walks you through the process of downloading the project and saving it locally. Important steps such as removing unnecessary imports and installing dependencies are covered.
You'll also learn how to publish the project to GitHub, ensuring to exclude sensitive files like API keys. Additionally, the video highlights the significance of ignoring or deleting the env.js file. The lesson concludes with guidance on setting up a Netlify account for future deployment. By following these steps, you'll be ready to seamlessly deploy your project without encountering any errors or frustrations.
[00:00] So firstly, we need to get our project stored locally. So come down here and click on this cog icon, and that will bring up a menu. Click Download as zip, and then unzip that folder and save it somewhere sensible. I've saved mine in this folder called wewingit-deploy, and it's inside another folder called apps.
[00:19] Now, let's open that in VS Code. Now, before we forget and to save us from running into an error later, I want to open up index.js and come on to line two. We won't be importing the API key like this anymore. So let's go ahead and delete that import statement. If you skip this step, when we deploy the project to Netlify,
[00:39] you will get an error and it will be a bit frustrating. So best to remember to do it now. Next, we need to open up the terminal, and I'll zoom in on it, and I'm going to run npm install, and this will download the dependencies defined in the package.json file, and it will generate a node modules folder with the installed modules.
[00:58] The dependency that we've been using is the OpenAI API, and we still need it when we deploy to Netlify. Okay, we run that, we let it do its thing, and then we can see that the node modules folder has appeared. The next step is to publish to GitHub. So you're welcome to do this in whichever way you're comfortable with.
[01:17] I've got the GitHub and pull requests extension installed, so I will go with this icon right here, and I'm going to come down here and click on publish to GitHub. I'm going to publish mine to a private repository. Now, it's asking me here which files should be included in the repository. Really important to ignore the env.js file,
[01:37] so I'll untick that. Now, you could also delete it. It doesn't matter if you delete it or ignore it, just make sure you don't include it in your repo. If you choose to delete it, make sure you've got a copy of it somewhere handy, as we will be using it again shortly. Okay, I'll click okay, I'll let VS Code do its thing,
[01:55] and then when the process has completed, we can see that we've got the gitignore file and env.js is in that file, so that is exactly what we want. And of course, at this point, you can log into GitHub and check it's worked if you want to be sure. Okay, so we've got the project stored in a repo. We've either ignored or deleted the API key.
[02:14] Next, we need to set up a Netlify account.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!