Loading video player…

From Script Tags to a Vite Project (Overview)

Generic Grocery Co.’s website is still plain HTML, CSS, and ES modules loaded with script tags, and its README has a fresh list of to-dos. The first one asks for an Open now badge that knows the store’s holiday hours, so on Christmas Eve it says Open now, until 3 p.m. (Christmas Eve hours). Working out when the store opens next takes date math that’s clumsy with JavaScript’s built-in Date, so the badge needs a small date library.

Teams install a library like this as an npm package, and the site’s code imports it by its name. A browser can’t find a package by its name, so once the badge imports it, the site needs a tool that serves it to the browser. That changes how the whole site runs.

In this course, you’ll turn the store’s site into a project that installs packages with npm and runs and builds with Vite, the setup that most JavaScript teams start a front-end project with today. You’ll do it on a branch, so main keeps the working site the whole time.

The store’s customers keep checking the opening hours throughout, and they never find out that their website was halfway through a move.

What You’ll Learn

This is the second course in the Tooling and Git for JavaScript Projects path, where you work on the same store’s site the way a professional team works on a project. If you’ve come to this course directly, you’re in the right place, because the starting code comes with everything the first course built, including its Git history.

The course takes the site from script tags to a Vite project, one section at a time:

  1. Moving to npm on a Branch starts the move on a vite branch of its own. You turn the site into an npm project, check a package before you install it, and commit the lockfile that records exactly what you installed.
  2. Running the Site With Vite adds the badge’s code, which stops the home page from working in the browser. Vite’s dev server brings it back, and the build makes the files you’d publish, all four pages of them.
  3. Merging Main Into Your Branch fixes two holiday hours on main, because they can’t wait for the move, and merges them into vite so your branch doesn’t fall behind.
  4. Project: Finish the Move hands you the remaining to-dos. You’ll show the deals for their week, take curbside pickup orders with the store’s key kept out of Git, and teach the badge to name the holiday. Last, you’ll merge vite into main and check it all with npm run check.
  5. Reviewing What You’ve Learned wraps up with a quiz and a look back at the habits you’ve built.

By the end, you’ll be able to turn a static site into an npm and Vite project on a branch. You’ll install and use a package, run the dev server, build the site, keep the lockfile and the secrets right, and merge the branch when it works. That’s the everyday workflow behind a front-end developer job, and a project you can talk through in an interview.

How the Course Works

Most lessons are text, and you follow along in your own terminal and editor. A few short videos picture what Git does with branches and merges, with their key points written out below them. Every lesson starts from a problem in the store’s project. Along the way, you’ll run into a few mistakes that almost everyone makes with npm and Vite. That’s expected, and each time, the lesson explains what happened and how to do it differently.

You’ll get the starting code in the next lesson. It’s the store’s site at the start of this course, as a ZIP that includes the hidden .git folder, so git log shows the whole history so far:

If you kept your own repository from the first course, then you can keep working in it instead, and the next lesson shows you which files to copy over.

The project has a check script that inspects your repository, and in this course it becomes npm run check. It marks each check with ✔, ✘ or !, and gives you a next step for every problem it finds. Quizzes and coding exercises let you test yourself, and at the end, the mentor reviews your project with you. Wherever you see a mentor button, click it to open a conversation with the mentor.

What You Should Know Already

This course assumes that you’ve written JavaScript and worked in a Git repository before. In particular, you should be comfortable with the following:

You don’t need any experience with npm or Vite. If you’ve pasted an npm install from a tutorial or an AI assistant without knowing what it did, that’s completely fine, because this course explains every command when you need it.

In the next lesson, you’ll get the store’s site onto your computer and check that it runs and that Git remembers every commit.

Download

Course Slides (.pdf)

326.3 KB
Download

Sample Code (.zip)

28.8 KB

00:00 Welcome to From Script Tags to a Vite Project.

00:05 Here’s Generic Grocery Co.’s home page at the end of the course. Its Open now badge knows the holiday hours, so on Christmas Eve it says the store closes at 3 p.m.

00:17 This is the store’s website, Git history and all, and the next lesson gives it to you, even if you’re new here. Its README’s first to-do, this badge, needs a date library.

00:29 You’ll install it with npm. Then the browser can’t load the site on its own, so Vite runs it. So you’ll make the move on a branch, a separate line of commits, while the main branch keeps the working site.

00:42 Meanwhile, the customers check the opening hours, none the wiser that their website is mid-move.

00:49 You’ll turn the site into an npm project and install a package once you’ve checked it’s safe to trust. You’ll run it on Vite’s dev server and build the files to publish.

01:00 Two holiday fixes can’t wait for the move, so they go on the main branch. You’ll merge them into yours. In the course project, you’ll add curbside pickup and keep its key out of Git.

01:13 Last, you’ll merge into the main branch and check it all with npm run check.

01:20 You should be comfortable with JavaScript modules, running Node scripts in a terminal, and committing with Git. You don’t need any npm experience. The starting code is a ZIP with its history, or you can keep your own repository.

01:36 Most lessons are text, with a few short videos, quizzes and coding exercises, and a review with the mentor at the end. In the next lesson, you’ll get the store’s site running on your computer.

Become a Member to join the conversation.