Svelte Course screenshot

Svelte Course

Author Avatar Theme by Alialaa
Updated: 9 Oct 2022
16 Stars

Categories

Overview:

This product analysis is about a template for developing with Svelte in Vite. It provides a starting point for beginners and demonstrates capabilities comparable to other create-vite templates. The template has been structured similarly to SvelteKit, making it easy to migrate to SvelteKit later if needed. It also includes some technical considerations and explanations for certain choices made in the template.

Features:

  • Easy development with Svelte in Vite: This template provides a starting point for developing with Svelte in Vite, making it easier for beginners to get started.
  • Good developer experience: The template takes into account the developer experience by considering HMR (Hot Module Replacement) and Intellisense.
  • Easy migration to SvelteKit: The template has been structured similarly to SvelteKit, making it easy to migrate to SvelteKit later if needed.
  • Accepts type information from entire workspace: The use of triple-slash references in the global.d.ts file allows the template to accept type information from the entire workspace, while also adding svelte and vite/client type information.
  • Prompt to install recommended extensions: The inclusion of .vscode/extensions.json allows VS Code to prompt the user to install the recommended extension upon opening the project.
  • Advanced typechecking with checkJs enabled: The template enables checkJs in the JS template to provide advanced typechecking out of the box. It helps catch accidental changes in variable types during runtime.
  • Guidance on HMR and component state preservation: The template provides an explanation about why HMR state preservation is disabled by default and suggests using an external store for important component state that needs to be retained.

Installation:

To install the template, follow these steps:

  1. Install Vite globally:
npm install -g create-vite
  1. Create a new project using the template:
create-vite my-svelte-project --template svelte
  1. Change to the project directory:
cd my-svelte-project
  1. Start the development server:
npm run dev

Summary:

The Svelte + Vite template provides a starting point for developing with Svelte in Vite. It offers a good developer experience by considering HMR and Intellisense. The template is structured similarly to SvelteKit, making it easy to migrate to SvelteKit later if needed. It also includes explanations for technical considerations such as type accepting, extension recommendations, checkJs usage, and HMR state preservation. Overall, this template is a useful tool for beginners and developers looking to develop with Svelte in Vite.