forked from hannoeru/vite-plugin-pages
-
Notifications
You must be signed in to change notification settings - Fork 0
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
31 changed files
with
871 additions
and
260 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"extends": "@antfu/eslint-config", | ||
"ignorePatterns": ["dist", "**/__*__/**"] | ||
"ignorePatterns": ["dist", "**/__*__/**"], | ||
"rules": { | ||
"no-use-before-define": "off" | ||
} | ||
} |
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,13 +1,17 @@ | ||
declare module 'pages-generated' { | ||
// eslint-disable-next-line import/no-duplicates | ||
import { RouteRecordRaw } from 'vue-router' | ||
const routes: RouteRecordRaw[] | ||
// eslint-disable-next-line import/no-duplicates | ||
import { RouteConfig } from 'react-router-config' | ||
const routes: RouteRecordRaw[] | RouteConfig[] | ||
export default routes | ||
} | ||
|
||
declare module 'virtual:generated-pages' { | ||
// eslint-disable-next-line import/no-duplicates | ||
import { RouteRecordRaw } from 'vue-router' | ||
const routes: RouteRecordRaw[] | ||
// eslint-disable-next-line import/no-duplicates | ||
import { RouteConfig } from 'react-router-config' | ||
const routes: RouteRecordRaw[] | RouteConfig[] | ||
export default routes | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
*.local |
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,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
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,27 @@ | ||
{ | ||
"name": "react", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "nodemon --watch ../../dist/*.js -x 'cross-env DEBUG=vite-plugin-pages:* vite'", | ||
"build": "cross-env DEBUG=vite-plugin-pages vite build", | ||
"serve": "vite preview" | ||
}, | ||
"dependencies": { | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"react-router": "^5.2.0", | ||
"react-router-config": "^5.1.1", | ||
"react-router-dom": "^5.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^17.0.4", | ||
"@types/react-dom": "^17.0.3", | ||
"@types/react-router-config": "^5.0.2", | ||
"@vitejs/plugin-react-refresh": "^1.3.3", | ||
"cross-env": "^7.0.3", | ||
"nodemon": "^2.0.7", | ||
"typescript": "^4.2.4", | ||
"vite": "^2.2.4", | ||
"vite-plugin-pages": "workspace:*" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,13 @@ | ||
body { | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', | ||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | ||
sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} | ||
|
||
code { | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', | ||
monospace; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,22 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import { | ||
BrowserRouter as Router, | ||
} from 'react-router-dom' | ||
import { renderRoutes } from 'react-router-config' | ||
import './index.css' | ||
import routes from 'virtual:generated-pages' | ||
|
||
console.log(routes) | ||
|
||
ReactDOM.render( | ||
<Router> | ||
{/* kick it all off with the root route */} | ||
{renderRoutes(routes)} | ||
</Router>, | ||
document.getElementById('root'), | ||
) | ||
|
||
export { | ||
routes, | ||
} |
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,9 @@ | ||
import React from 'react' | ||
|
||
const all: React.FC = () => { | ||
return ( | ||
<p>...all route</p> | ||
) | ||
} | ||
|
||
export default all |
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,9 @@ | ||
import React from 'react' | ||
|
||
const current: React.FC = () => { | ||
return ( | ||
<p>/[sensor]/current.vue</p> | ||
) | ||
} | ||
|
||
export default current |
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,9 @@ | ||
import React from 'react' | ||
|
||
const index: React.FC = () => { | ||
return ( | ||
<p>test default exclude</p> | ||
) | ||
} | ||
|
||
export default index |
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,14 @@ | ||
import React from 'react' | ||
import { renderRoutes, RouteConfigComponentProps } from 'react-router-config' | ||
|
||
const component: React.FC<RouteConfigComponentProps> = ({ route }) => { | ||
return ( | ||
<> | ||
<p>nested about view:</p> | ||
{renderRoutes(route?.routes)} | ||
{console.log(route)} | ||
</> | ||
) | ||
} | ||
|
||
export default component |
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,9 @@ | ||
import React from 'react' | ||
|
||
const index: React.FC = () => { | ||
return ( | ||
<p>about/index.vue</p> | ||
) | ||
} | ||
|
||
export default index |
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,13 @@ | ||
import React from 'react' | ||
import { matchRoutes, RouteConfigComponentProps } from 'react-router-config' | ||
import routes from 'virtual:generated-pages' | ||
|
||
const components: React.FC<RouteConfigComponentProps> = ({ location }) => { | ||
return ( | ||
<> | ||
<p>blog/[id].vue: { matchRoutes<{ id: string }>(routes, location.pathname)[0].match.params.id }</p> | ||
</> | ||
) | ||
} | ||
|
||
export default components |
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,18 @@ | ||
import React from 'react' | ||
import { Link } from 'react-router-dom' | ||
|
||
const components: React.FC = () => { | ||
return ( | ||
<> | ||
<p>blog/index.vue</p> | ||
<Link to="/blog/1b234bk12b3"> | ||
id: 1b234bk12b3 | ||
</Link> | | ||
<Link to="/blog/today"> | ||
today | ||
</Link> | ||
</> | ||
) | ||
} | ||
|
||
export default components |
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,9 @@ | ||
import React from 'react' | ||
|
||
const index: React.FC = () => { | ||
return ( | ||
<p>blog/today/index.vue</p> | ||
) | ||
} | ||
|
||
export default index |
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,9 @@ | ||
import React from 'react' | ||
|
||
const components: React.FC = () => { | ||
return ( | ||
<h1>Test Components name</h1> | ||
) | ||
} | ||
|
||
export default components |
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,27 @@ | ||
import React from 'react' | ||
import { Link } from 'react-router-dom' | ||
|
||
const index: React.FC = () => { | ||
return ( | ||
<div> | ||
<p>index.vue</p> | ||
<Link to="/blog"> | ||
blog | ||
</Link> | | ||
<Link to="/about"> | ||
about | ||
</Link> | | ||
<Link to="/components"> | ||
components | ||
</Link> | | ||
<Link to="/markdown"> | ||
markdown | ||
</Link> | | ||
<Link to="/xxx"> | ||
not exits | ||
</Link> | ||
</div> | ||
) | ||
} | ||
|
||
export default index |
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,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"lib": ["DOM", "DOM.Iterable", "ESNext"], | ||
"types": ["vite/client"], | ||
"allowJs": false, | ||
"skipLibCheck": false, | ||
"esModuleInterop": false, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "react" | ||
}, | ||
"include": ["./src"] | ||
} |
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,21 @@ | ||
import { defineConfig } from 'vite' | ||
import reactRefresh from '@vitejs/plugin-react-refresh' | ||
import Pages from 'vite-plugin-pages' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [ | ||
reactRefresh(), | ||
Pages({ | ||
pagesDir: [ | ||
{ dir: 'src/pages', baseRoute: '' }, | ||
{ dir: 'src/features/admin/pages', baseRoute: 'admin' }, | ||
], | ||
extensions: ['tsx'], | ||
syncIndex: false, | ||
importMode: 'sync', | ||
replaceSquareBrackets: true, | ||
react: true, | ||
}), | ||
], | ||
}) |
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
Oops, something went wrong.