build: fix build and add examples
This commit is contained in:
13
examples/react-tanstack-router/.gitignore
vendored
Normal file
13
examples/react-tanstack-router/.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Local
|
||||
.DS_Store
|
||||
*.local
|
||||
*.log*
|
||||
|
||||
# Dist
|
||||
node_modules
|
||||
dist/
|
||||
|
||||
# IDE
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
29
examples/react-tanstack-router/README.md
Normal file
29
examples/react-tanstack-router/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Rsbuild project
|
||||
|
||||
## Setup
|
||||
|
||||
Install the dependencies:
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
|
||||
## Get started
|
||||
|
||||
Start the dev server:
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
Build the app for production:
|
||||
|
||||
```bash
|
||||
pnpm build
|
||||
```
|
||||
|
||||
Preview the production build locally:
|
||||
|
||||
```bash
|
||||
pnpm preview
|
||||
```
|
||||
23
examples/react-tanstack-router/package.json
Normal file
23
examples/react-tanstack-router/package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "react-tanstack-router",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"dev": "rsbuild dev",
|
||||
"build": "rsbuild build",
|
||||
"preview": "rsbuild preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/react-router": "^1.99.6",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rsbuild/core": "^1.2.3",
|
||||
"@rsbuild/plugin-react": "^1.1.0",
|
||||
"@types/react": "^19.0.8",
|
||||
"@types/react-dom": "^19.0.3",
|
||||
"oidc-client-rx": "workspace:*",
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
0
examples/react-tanstack-router/public/.gitkeep
Normal file
0
examples/react-tanstack-router/public/.gitkeep
Normal file
6
examples/react-tanstack-router/rsbuild.config.ts
Normal file
6
examples/react-tanstack-router/rsbuild.config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { defineConfig } from '@rsbuild/core';
|
||||
import { pluginReact } from '@rsbuild/plugin-react';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [pluginReact()],
|
||||
});
|
||||
26
examples/react-tanstack-router/src/App.css
Normal file
26
examples/react-tanstack-router/src/App.css
Normal file
@@ -0,0 +1,26 @@
|
||||
body {
|
||||
margin: 0;
|
||||
color: #fff;
|
||||
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
|
||||
background-image: linear-gradient(to bottom, #020917, #101725);
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
line-height: 1.1;
|
||||
text-align: center;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.content h1 {
|
||||
font-size: 3.6rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.content p {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 400;
|
||||
opacity: 0.5;
|
||||
}
|
||||
15
examples/react-tanstack-router/src/App.tsx
Normal file
15
examples/react-tanstack-router/src/App.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { useOidcClient } from 'oidc-client-rx/adapters/react';
|
||||
import './App.css';
|
||||
|
||||
const App = () => {
|
||||
const { oidcSecurityService } = useOidcClient();
|
||||
|
||||
return (
|
||||
<div className="content">
|
||||
<h1>Rsbuild with React</h1>
|
||||
<p>Start building amazing things with Rsbuild.</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
1
examples/react-tanstack-router/src/env.d.ts
vendored
Normal file
1
examples/react-tanstack-router/src/env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="@rsbuild/core/types" />
|
||||
40
examples/react-tanstack-router/src/index.tsx
Normal file
40
examples/react-tanstack-router/src/index.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { type Injector, ReflectiveInjector } from '@outposts/injection-js';
|
||||
import { LogLevel, OidcSecurityService, provideAuth } from 'oidc-client-rx';
|
||||
import { InjectorProvider } from 'oidc-client-rx/adapters/react';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import App from './App';
|
||||
|
||||
const rootEl = document.getElementById('root');
|
||||
|
||||
if (rootEl) {
|
||||
const injector = ReflectiveInjector.resolveAndCreate(
|
||||
provideAuth({
|
||||
config: {
|
||||
authority: '<your authority address here>',
|
||||
redirectUrl: window.location.origin,
|
||||
postLogoutRedirectUri: window.location.origin,
|
||||
clientId: '<your clientId>',
|
||||
scope: 'openid profile email offline_access',
|
||||
responseType: 'code',
|
||||
silentRenew: true,
|
||||
useRefreshToken: true,
|
||||
logLevel: LogLevel.Debug,
|
||||
},
|
||||
})
|
||||
) as Injector;
|
||||
|
||||
// if needed, check when init
|
||||
const oidcSecurityService = injector.get(OidcSecurityService);
|
||||
oidcSecurityService.checkAuthMultiple();
|
||||
|
||||
const root = ReactDOM.createRoot(rootEl);
|
||||
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<InjectorProvider injector={injector}>
|
||||
<App />
|
||||
</InjectorProvider>
|
||||
</React.StrictMode>
|
||||
);
|
||||
}
|
||||
18
examples/react-tanstack-router/tsconfig.json
Normal file
18
examples/react-tanstack-router/tsconfig.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"rootDir": ".",
|
||||
"lib": ["ES2021", "DOM", "DOM.Iterable"],
|
||||
"useDefineForClassFields": true,
|
||||
"resolveJsonModule": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"noEmit": true,
|
||||
"outDir": "./dist",
|
||||
"declarationDir": "./dist",
|
||||
"jsx": "preserve"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
Reference in New Issue
Block a user