Comprehensive Guide to Setting Up a Svelte Project Using Git
This guide will walk you through the process of setting up a Svelte project using Git. By following these steps, you can quickly and confidently start your project.
1. Initial Setup
Application Name
First, choose a suitable name for your application. This name will be used as the identifier in your project's domain.
- Use lowercase letters and only - as a separator between words.
- You cannot change the application name after creating the app.
Node Version
Selecting the appropriate Node version for your project is crucial. Choose from the available list or enter your desired version. Note that the selected version must be available in Docker repositories (e.g., DockerHub).
Repository
Repository URL
Enter the Git repository URL for your project. Example: https://github.com/username/repo
Ensure that the package.json
file exists in your project.
Repository Type and Access
- Public: Enter the URL directly.
- Private: You can connect your private repository to Kubar in two ways:
Connect with Access Token
Connect with SSH Key
After completing this step, select the "Next" option.
2. Advanced Settings (Optional)
In this section, you can apply more precise settings for your project:
Build
Sample package.json file:
{
"name": "my-svelte-project",
"version": "0.0.1",
"private": true,
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "eslint .",
"format": "prettier --write ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.3"
},
"dependencies": {
},
"engines": {
"node": ">=18.0.0"
}
}
Build Command
- Specific command(s) for building the project
- Default:
npm run build
- To use multiple commands, use ; as a separator (example:
npm run build;npm run start
)
Run Command
- Command to run the project
- For Svelte.js, it is better not to enter a command
Output Folder
- Location of the built files
- Default:
dist/
Port
Specify the port number on which your application will run. The default port is 5173, but you can change it.
- After the initial setup, you can change the port
- When specifying the port, always use the address
0.0.0.0
.
Resource Scheduling
Disk
Environment Variables
4. Plan Selection
In this step, select your desired plan. You can choose from the available list or configure it manually.
Replica
Specify the number of replicas (executable instances) for your application. This number affects the performance and availability of your application.
Importance of Replica Count
- Scalability: Increase processing power by increasing the number of replicas
- High Availability: Maintain performance in case one instance fails
- Load Distribution: Distribute load across multiple instances
After selecting the desired plan, choose the Create App option.
5. Project Management
After setup, various management features will be available to you:
-
Check project status
-
Manage connections and resources
-
Manage ports
infoThe port you defined in your project must also be defined in this section.
-
Change Dockerfile name (if needed)
tipIf your project requires very specific settings, you can create your own Dockerfile. For more information, refer to this link.
-
Change build command
-
Change run command
-
Specify output folder location
-
Manage Git repository and rebuild operations
-
Set project branch
-
Restart project
If you want to use multiple commands for building the project, use ; as a separator (e.g., npm run build;npm run start
)
Using these features, you can efficiently and professionally manage your Svelte project.