TheOdinProject / curriculum

The open curriculum for learning web development
https://www.theodinproject.com/
Other
9.87k stars 13.21k forks source link

Restaurant Page: Inhouse deployment instructions #28780

Closed damon314159 closed 6 days ago

damon314159 commented 2 weeks ago

Checks

Describe your suggestion

The current instructions defer to this gist, which works fine for the first deployment, but causes some friction in one way or another when a user needs to make a change to their src and redeploy.

The gist has the user commit dist to main, which learners are previously told they should avoid, but it does work. However when the user next makes changes and redeploy, the same gist will fail with a "current branch behind remote" warning. This can't be solved with a pull, since what's going on here is one local branch is trying to correspond to two remote branches at once. The whole situation gets confusing.

I propose an alternate workflow that:

# Initial deployment

# Make sure you have committed all your source files first
git checkout -b gh-pages
npx webpack --mode='production'
git add dist -f && git commit -m "Deployment commit"
git subtree push --prefix dist origin gh-pages
git checkout main

# Redeploying changes

# Make sure you have committed all your source files first
git checkout gh-pages && git merge main --no-edit
npx webpack --mode='production'
git add dist -f && git commit -m "Deployment commit"
git subtree push --prefix dist origin gh-pages
git checkout main

The webpack command can be swapped out with whatever the user's build command looks like

Path

Node / JS

Lesson Url

https://www.theodinproject.com/lessons/node-path-javascript-restaurant-page

(Optional) Discord Name

No response

(Optional) Additional Comments

No response

MaoShizhong commented 1 week ago

Thanks @damon314159. I'll take a look at this properly in due course, but so far looks promising!

MaoShizhong commented 6 days ago

I like it @damon314159. We can split off the deployment to its own assignment subsection (rather than a step 8), then perhaps briefly explain each step as necessary?

Since this is for the Restaurant Page, we can omit the production mode bit since that won't be mentioned until the next lesson. Perhaps the explanation for that bit might say something like "Now let's bundle our application into dist with our build command. For now, that's npx webpack." or something like that.

I'll assign this to you.