Skip to content

Commit 2f6d882

Browse files
committed
feat(create-rstack): add Svelte app templates
1 parent 00fab61 commit 2f6d882

23 files changed

Lines changed: 302 additions & 0 deletions

‎packages/create-rstack/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ npx create-rstack -d my-project -t app-vanilla-ts
2727
- `app-react-ts` - TypeScript React application
2828
- `app-vue-js` - JavaScript Vue application
2929
- `app-vue-ts` - TypeScript Vue application
30+
- `app-svelte-js` - JavaScript Svelte application
31+
- `app-svelte-ts` - TypeScript Svelte application
3032
- `app-solid-js` - JavaScript Solid application
3133
- `app-solid-ts` - TypeScript Solid application
3234
- `lib-node-js` - JavaScript Node.js library

‎packages/create-rstack/src/index.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const getTemplateName = async ({ template }: Argv): Promise<string> => {
7575
{ value: 'vanilla', label: 'Vanilla' },
7676
{ value: 'react', label: 'React' },
7777
{ value: 'vue', label: 'Vue' },
78+
{ value: 'svelte', label: 'Svelte' },
7879
{ value: 'solid', label: 'Solid' },
7980
]
8081
: [
@@ -109,6 +110,8 @@ await create({
109110
'app-react-ts',
110111
'app-vue-js',
111112
'app-vue-ts',
113+
'app-svelte-js',
114+
'app-svelte-ts',
112115
'app-solid-js',
113116
'app-solid-ts',
114117
'lib-node-js',
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# AGENTS.md
2+
3+
## Commands
4+
5+
- `{{ packageManager }} run dev` - Start the development server
6+
- `{{ packageManager }} run build` - Build the app for production
7+
- `{{ packageManager }} run preview` - Preview the production build locally
8+
- `{{ packageManager }} run test` - Run tests
9+
- `{{ packageManager }} run test:watch` - Run tests in watch mode
10+
11+
## Docs
12+
13+
- Rsbuild: https://rsbuild.rs/llms.txt
14+
- Rspack: https://rspack.rs/llms.txt
15+
- Rstest: https://rstest.rs/llms.txt
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "rstack-app-svelte-js",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"build": "rs build",
8+
"dev": "rs dev",
9+
"format": "rs fmt",
10+
"lint": "rs lint",
11+
"preview": "rs preview",
12+
"test": "rs test",
13+
"test:watch": "rs test --watch"
14+
},
15+
"dependencies": {
16+
"svelte": "^5.56.8"
17+
},
18+
"devDependencies": {
19+
"@rsbuild/plugin-svelte": "^2.0.1",
20+
"@testing-library/jest-dom": "^7.0.0",
21+
"@testing-library/svelte": "^5.4.2",
22+
"happy-dom": "^20.11.1",
23+
"rstack": "^0.3.5"
24+
}
25+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
allowBuilds:
2+
svelte-preprocess: false
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// @ts-check
2+
// Rstack configuration guide: https://rstack.rs/config
3+
import { define } from 'rstack';
4+
5+
define.app(async () => {
6+
const { pluginSvelte } = await import('@rsbuild/plugin-svelte');
7+
8+
return {
9+
plugins: [pluginSvelte()],
10+
};
11+
});
12+
13+
define.test({
14+
setupFiles: ['./tests/rstest.setup.js'],
15+
});
16+
17+
define.lint(async () => {
18+
const { js } = await import('rstack/lint');
19+
20+
return [js.configs.recommended];
21+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<main>
2+
<div class="content">
3+
<h1>Rstack with Svelte</h1>
4+
<p>Start building amazing things with Rstack.</p>
5+
</div>
6+
</main>
7+
8+
<style>
9+
.content {
10+
display: flex;
11+
min-height: 100vh;
12+
line-height: 1.1;
13+
text-align: center;
14+
flex-direction: column;
15+
justify-content: center;
16+
}
17+
18+
.content h1 {
19+
font-size: 3.6rem;
20+
font-weight: 700;
21+
}
22+
23+
.content p {
24+
font-size: 1.2rem;
25+
font-weight: 400;
26+
opacity: 0.5;
27+
}
28+
</style>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
body {
2+
margin: 0;
3+
color: #fff;
4+
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
5+
background-image: linear-gradient(to bottom, #020917, #101725);
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { mount } from 'svelte';
2+
import App from './App.svelte';
3+
import './index.css';
4+
5+
const root = document.getElementById('root');
6+
if (root) {
7+
mount(App, { target: root });
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { render, screen } from '@testing-library/svelte';
2+
import { expect, test } from 'rstack/test';
3+
import App from '../src/App.svelte';
4+
5+
test('renders the main page', () => {
6+
render(App);
7+
expect(screen.getByText('Rstack with Svelte')).toBeInTheDocument();
8+
});

0 commit comments

Comments
 (0)