Skip to content

Commit 5f6d2f3

Browse files
committed
feat: add an minimal projet for devServer tests
1 parent a1d0077 commit 5f6d2f3

File tree

9 files changed

+79
-0
lines changed

9 files changed

+79
-0
lines changed

tests/example/src/page1/App.jsx

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { useState } from 'react'
2+
import "./assets/index.css"
3+
function App() {
4+
const [count, setCount] = useState(0)
5+
return (
6+
<div className="App">
7+
<button onClick={() => setCount((count) => count + 1)}>
8+
count is {count}
9+
</button>
10+
</div>
11+
)
12+
}
13+
export default App
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:root{background-color:#fff}

tests/example/src/page1/config.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"template": "tests/example/templates/tpl.html"
3+
}

tests/example/src/page1/main.jsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
import ReactDOM from 'react-dom/client'
3+
import App from './App'
4+
5+
ReactDOM.createRoot(document.getElementById('root')).render(
6+
<React.StrictMode>
7+
<App />
8+
</React.StrictMode>,
9+
)

tests/example/src/page2/App.jsx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { useState } from 'react'
2+
function App() {
3+
const [count, setCount] = useState(0)
4+
return (
5+
<div className="App">
6+
<button onClick={() => setCount((count) => count + 1)}>
7+
count is {count}
8+
</button>
9+
</div>
10+
)
11+
}
12+
export default App

tests/example/src/page2/config.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"template": "tests/example/templates/tpl.html"
3+
}

tests/example/src/page2/main.jsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
import ReactDOM from 'react-dom/client'
3+
import App from './App'
4+
5+
ReactDOM.createRoot(document.getElementById('root')).render(
6+
<React.StrictMode>
7+
<App />
8+
</React.StrictMode>,
9+
)

tests/example/templates/tpl.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Minimal React Vite Project</title>
8+
</head>
9+
10+
<body>
11+
<div id="root"></div>
12+
<script type="module" src="/src/main.jsx"></script>
13+
</body>
14+
15+
</html>

tests/example/vite.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from 'vite'
2+
import react from '@vitejs/plugin-react'
3+
import autoMpaHTMLPlugin from '../../lib/index'
4+
5+
// https://vitejs.dev/config/
6+
export default defineConfig({
7+
plugins: [react(), autoMpaHTMLPlugin({
8+
sourceDir: "src",
9+
configName: "config.json",
10+
entryName: "main.jsx",
11+
sharedData: {},
12+
ejsOption: {},
13+
})],
14+
})

0 commit comments

Comments
 (0)