Run and Build Svelte with Parcel

Andrew Smith
InstructorAndrew Smith

Share this video with your friends

Send Tweet
Published 4 years ago
Updated 3 years ago

In this lesson, you will learn how to setup the zero configuration blazing fast web application bundler Parcel with Svelte.

Instructor: [00:00] Let's start by creating a package.json file using npm init -y. Now let's install parcel, parcel-svelte, and svelte as dev dependencies.

[00:10] Inside our editor, create the index.html file inside of the root directory and create a source directory containing our main.js file. Open the index.html file and add some basic HTML structure including a script tag pointing to the main.js file.

[00:28] Let's edit the package.json file and add two entries to the script section. First, we add the command for parcel development server. Let's copy this and create the second command for the production build. Let's add another entry to our package.json file containing browsers list. This will be used by parcel when compiling.

[00:48] Now let's create the app.svelte file inside of this source directory and add some svelte code. Edit the main.js file and add the instantiation code for svelte component we just made. Open your terminal and run the parcel development server using npm start. Now open your browser and visit localhost:1234.

[01:10] Let's recap what we did. We installed parcel, svelte, and the parcel-svelte-plugin in order to compile svelte components. We set up the parcel development server and the production build command in our package.json file. Then, we created a simple svelte component to test it out.