-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
187 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
packages/create-app/template-react-admin-ts/src/layout/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import React from "react"; | ||
import { Outlet } from "viter"; | ||
|
||
function Layout(props) { | ||
return <div>{props.children}</div>; | ||
function Layout() { | ||
return ( | ||
<div style={{ backgroundColor: "GrayText", height: "400px" }}> | ||
<Outlet></Outlet> | ||
</div> | ||
); | ||
} | ||
|
||
export default Layout; |
4 changes: 2 additions & 2 deletions
4
packages/create-app/template-react-admin-ts/src/loading/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import React from 'react'; | ||
import React from "react"; | ||
|
||
function Loading() { | ||
return <div>Loading</div>; | ||
return <div style={{ color: "#fff" }}>Loading</div>; | ||
} | ||
|
||
export default Loading; |
7 changes: 7 additions & 0 deletions
7
packages/create-app/template-react-admin-ts/src/pages/About/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
|
||
function About() { | ||
return <div>about us</div>; | ||
} | ||
|
||
export default About; |
42 changes: 42 additions & 0 deletions
42
packages/create-app/template-react-admin-ts/src/pages/Home/Home.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.App { | ||
text-align: center; | ||
} | ||
|
||
.App-logo { | ||
height: 40vmin; | ||
pointer-events: none; | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: white; | ||
} | ||
|
||
.App-link { | ||
color: #61dafb; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
button { | ||
font-size: calc(10px + 2vmin); | ||
} |
43 changes: 43 additions & 0 deletions
43
packages/create-app/template-react-admin-ts/src/pages/Home/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { useState } from "react"; | ||
import styles from "./Home.module.css"; | ||
|
||
function Home() { | ||
const [count, setCount] = useState(0); | ||
|
||
return ( | ||
<div className="App"> | ||
<header className={styles["App-header"]}> | ||
<p>Hello Viter + React!</p> | ||
<p> | ||
<button onClick={() => setCount((count) => count + 1)}> | ||
count is: {count} | ||
</button> | ||
</p> | ||
<p> | ||
Edit <code>Home.tsx</code> and save to test HMR updates. | ||
</p> | ||
<p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
{" | "} | ||
<a | ||
className="App-link" | ||
href="https://vitejs.dev/guide/features.html" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Vite Docs | ||
</a> | ||
</p> | ||
</header> | ||
</div> | ||
); | ||
} | ||
|
||
export default Home; |
7 changes: 7 additions & 0 deletions
7
packages/create-app/template-react-admin-ts/src/pages/NotFind/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from "react"; | ||
|
||
function NotFind() { | ||
return <div>404 NotFind</div>; | ||
} | ||
|
||
export default NotFind; |
11 changes: 0 additions & 11 deletions
11
packages/create-app/template-react-admin-ts/src/pages/TestA/index.tsx
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
packages/create-app/template-react-admin-ts/src/pages/TestB/index.tsx
This file was deleted.
Oops, something went wrong.
21 changes: 18 additions & 3 deletions
21
packages/create-app/template-react-admin-ts/viter.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
import { defineConfig } from 'vite'; | ||
import reactRefresh from '@vitejs/plugin-react-refresh'; | ||
const { resolve } = require('path'); | ||
import { defineConfig } from "viter"; | ||
import reactRefresh from "@vitejs/plugin-react-refresh"; | ||
const { resolve } = require("path"); | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [reactRefresh()], | ||
routes: [ | ||
{ | ||
path: "/", | ||
component: "@/layout", | ||
routes: [ | ||
{ path: "/home", component: "./Home" }, | ||
{ path: "/about", component: "./About" }, | ||
{ path: "/404", component: "./NotFind" }, | ||
{ path: "/*", redirect: "/404" }, | ||
], | ||
}, | ||
], | ||
dynamicImport: { | ||
loading: "@/loading", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,64 @@ | ||
import path from 'path'; | ||
import rollupBaseConfig from '../../rollup.config'; | ||
import pkg from './package.json'; | ||
|
||
import { cloneDeep, merge } from 'lodash'; | ||
const external = [ | ||
'fsevents', | ||
'anymatch', | ||
'is-binary-path', | ||
'object-assign', | ||
'vite', | ||
...Object.keys(pkg.peerDependencies), | ||
]; | ||
|
||
export default Object.assign(rollupBaseConfig, { | ||
input: { | ||
index: './src/index.ts', | ||
cli: './src/cli.ts', | ||
}, | ||
output: [ | ||
{ | ||
export default [ | ||
merge(cloneDeep(rollupBaseConfig), { | ||
input: { | ||
index: './src/index.ts', | ||
cli: './src/cli.ts', | ||
}, | ||
output: { | ||
dir: path.resolve(__dirname, 'dist/cjs'), | ||
entryFileNames: `[name].js`, | ||
chunkFileNames: 'chunks/dep-[hash].js', | ||
exports: 'named', | ||
format: 'cjs', | ||
sourcemap: true, | ||
}, | ||
{ | ||
|
||
external, | ||
onwarn(warning, warn) { | ||
// vite use the eval('require') trick to deal with optional deps | ||
if (warning.message.includes('Use of eval')) { | ||
return; | ||
} | ||
if (warning.message.includes('Circular dependency')) { | ||
return; | ||
} | ||
warn(warning); | ||
}, | ||
}), | ||
merge(cloneDeep(rollupBaseConfig), { | ||
input: { | ||
runtime: './src/runtime.ts', | ||
}, | ||
output: { | ||
dir: path.resolve(__dirname, 'dist/esm'), | ||
entryFileNames: `[name].js`, | ||
chunkFileNames: 'chunks/dep-[hash].js', | ||
format: 'es', | ||
sourcemap: true, | ||
}, | ||
], | ||
external, | ||
onwarn(warning, warn) { | ||
// vite use the eval('require') trick to deal with optional deps | ||
if (warning.message.includes('Use of eval')) { | ||
return; | ||
} | ||
if (warning.message.includes('Circular dependency')) { | ||
return; | ||
} | ||
warn(warning); | ||
}, | ||
}); | ||
external, | ||
onwarn(warning, warn) { | ||
// vite use the eval('require') trick to deal with optional deps | ||
if (warning.message.includes('Use of eval')) { | ||
return; | ||
} | ||
if (warning.message.includes('Circular dependency')) { | ||
return; | ||
} | ||
warn(warning); | ||
}, | ||
}), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
export * from '@viter/runtime'; | ||
|
||
export * from './config'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@viter/runtime'; |