A modern template for Svelte projects using TypeScript and Vite as a bundler. This repository serves as a starting point for new Svelte projects with an optimized, ready-to-use configuration.
This template includes:
Using GitHub
# Clone this template
gh repo create my-project --template svelte-ts-skeleton-starter
# or use GitHub's interface to create a new repository from this template
Manually
# Clone the repository
git clone https://github.com/your-username/svelte-ts-skeleton-starter.git my-project
# Remove Git history
cd my-project
rm -rf .git
# Initialize a new Git repository
git init
Project Initialization
npm create vite@latest svelte-ts-skeleton-starter -- --template svelte-ts
cd svelte-ts-skeleton-starter
npm install
Project Structure
š¦ svelte-ts-skeleton-starter
āāā š public/
ā āāā vite.svg
āāā š src/
ā āāā š assets/
ā ā āāā svelte.svg
ā āāā š lib/
ā ā āāā Counter.svelte
ā āāā š styles/
ā ā āāā global.css
ā āāā app.css
ā āāā App.svelte
ā āāā main.ts
ā āāā vite-env.d.ts
āāā index.html
āāā package.json
āāā svelte.config.js
āāā tsconfig.json
āāā tsconfig.node.json
āāā vite.config.ts
svelte
: ^5.23.1@skeletonlabs/skeleton
: ^3.1.3svelte-i18n
: ^4.0.0 # Internationalization library@sveltejs/vite-plugin-svelte
: ^5.0.3@tsconfig/svelte
: ^5.0.4svelte-check
: ^4.1.5typescript
: ~5.7.2vite
: ^6.3.1{
"dev": "vite", // Starts the development server
"build": "vite build", // Generates production build
"preview": "vite preview", // Preview production version
"check": "svelte-check" // Runs TypeScript type checking
}
The project uses TypeScript with the following main configurations:
Clone the repository
git clone [REPOSITORY-URL]
Install dependencies
npm install
Start the development server
npm run dev
Access the project
The project will be available at http://localhost:5173
/public
: Static files that will be served directly/src
: Application source code/assets
: Resources such as images and icons/components
: User interface componentsLanguageSelector.svelte
: Component for language switchingThemeToggle.svelte
: Component for toggling between light/dark themes/lib
: Reusable components and shared functionalitiesi18n.ts
: Internationalization system/locales
: Translation files for different languagesen.ts
: English translationspt.ts
: Portuguese translationses.ts
: Spanish translations/styles
: Global style filesApp.svelte
: Root application componentmain.ts
: Application entry pointThe project uses TypeScript for:
This project includes a complete setup for unit and end-to-end (E2E) tests.
We use Vitest for unit tests with the following features:
Available commands:
# Run tests in watch mode (development)
npm test
# Run tests once
npm run test:run
# Run tests with coverage report
npm run test:coverage
npm run coverage
The internationalization system has comprehensive unit tests that verify:
We use Playwright for E2E tests with the following features:
Available commands:
# Run all E2E tests
npm run e2e
# Run E2E tests with visual interface
npm run e2e:ui
# View E2E test report
npm run e2e:report
The E2E tests for internationalization ensure that:
These tests use an approach based on the role and name of elements (getByRole
, getByText
), which makes the tests more robust and less susceptible to breaking due to changes in HTML or CSS structure.
The project includes specific accessibility tests for:
To run all tests (unit and E2E) at once:
npm run test:all
To create a production build:
npm run build
This will generate an optimized version of the project in the dist/
folder.
This project is configured for deployment to GitHub Pages using GitHub Actions with a modern CI/CD approach.
To configure GitHub Pages in your repository:
The project uses two separate workflows:
Build and Test (CI) .github/workflows/test-coverage.yml
main
branchmain
branchDeploy to GitHub Pages (CD) .github/workflows/deploy.yml
gh-pages
branchAfter deployment, the gh-pages
branch will have the following structure:
/
- Root with the main application/coverage/
- Test coverage reports (when published)The project uses the following branch scheme:
main
: Main development branchgh-pages
: Branch where the compiled site is published (do not edit manually)Deploy commits include [skip ci]
in the message to prevent the deployment from triggering new workflows, preventing infinite loops.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)For questions and support, please open an issue in the project repository.