Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Run and Build Svelte with Parcel

    Andrew SmithAndrew Smith
    sveltesvelte

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

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: 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.

    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.

    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.

    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.

    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.