Skip to content

Commit 0218f3d

Browse files
committed
feat(create-rstack): add Preact app templates
1 parent 22bdcfe commit 0218f3d

20 files changed

Lines changed: 295 additions & 0 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const getTemplateName = async ({ template }: Argv): Promise<string> => {
7474
? [
7575
{ value: 'vanilla', label: 'Vanilla' },
7676
{ value: 'react', label: 'React' },
77+
{ value: 'preact', label: 'Preact' },
7778
{ value: 'vue', label: 'Vue' },
7879
{ value: 'svelte', label: 'Svelte' },
7980
{ value: 'solid', label: 'Solid' },
@@ -108,6 +109,8 @@ await create({
108109
'app-vanilla-ts',
109110
'app-react-js',
110111
'app-react-ts',
112+
'app-preact-js',
113+
'app-preact-ts',
111114
'app-vue-js',
112115
'app-vue-ts',
113116
'app-svelte-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-preact-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+
"preact": "^10.29.8"
17+
},
18+
"devDependencies": {
19+
"@rsbuild/plugin-preact": "^2.0.0",
20+
"@testing-library/jest-dom": "^7.0.0",
21+
"@testing-library/preact": "^3.2.4",
22+
"happy-dom": "^20.11.1",
23+
"rstack": "^0.3.5"
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// @ts-check
2+
// Rstack configuration guide: https://rstack.rs/config
3+
import { define } from 'rstack';
4+
5+
define.app(async () => {
6+
const { pluginPreact } = await import('@rsbuild/plugin-preact');
7+
8+
return {
9+
plugins: [pluginPreact()],
10+
};
11+
});
12+
13+
define.test({
14+
setupFiles: ['./tests/rstest.setup.js'],
15+
});
16+
17+
define.lint(async () => {
18+
const { js, reactHooksPlugin, reactPlugin } = await import('rstack/lint');
19+
20+
return [
21+
js.configs.recommended,
22+
reactPlugin.configs.recommended,
23+
reactHooksPlugin.configs.recommended,
24+
];
25+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
}
7+
8+
.content {
9+
display: flex;
10+
min-height: 100vh;
11+
line-height: 1.1;
12+
text-align: center;
13+
flex-direction: column;
14+
justify-content: center;
15+
}
16+
17+
.content h1 {
18+
font-size: 3.6rem;
19+
font-weight: 700;
20+
}
21+
22+
.content p {
23+
font-size: 1.2rem;
24+
font-weight: 400;
25+
opacity: 0.5;
26+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import './App.css';
2+
3+
const App = () => {
4+
return (
5+
<div className="content">
6+
<h1>Rstack with Preact</h1>
7+
<p>Start building amazing things with Rstack.</p>
8+
</div>
9+
);
10+
};
11+
12+
export default App;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { render } from 'preact';
2+
import App from './App';
3+
4+
render(<App />, document.getElementById('root'));
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/preact';
2+
import { expect, test } from 'rstack/test';
3+
import App from '../src/App';
4+
5+
test('renders the main page', () => {
6+
render(<App />);
7+
expect(screen.getByText('Rstack with Preact')).toBeInTheDocument();
8+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { expect } from 'rstack/test';
2+
import * as jestDomMatchers from '@testing-library/jest-dom/matchers';
3+
4+
expect.extend(jestDomMatchers);
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

0 commit comments

Comments
 (0)