-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: SSR in mode vite ssr #5045
Merged
Merged
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
3658786
feat: vite ssr
ClarkXia 5ad669a
chore: fix unexpected remove
ClarkXia eeddcbd
fix: ts type
ClarkXia 2eee0f3
Merge branch 'release-next' into feat-vite-ssr
ClarkXia fbc601a
feat: ssr build in vite mode
ClarkXia 066ad26
chore: optimize code
ClarkXia 7c505f6
fix: optimize code
ClarkXia 5f87e6e
fix: ssr in dev
ClarkXia a0e164e
Merge branch 'release/2.5.0' into feat-vite-ssr
ClarkXia 8f77507
chore: version and changelog
ClarkXia db89b4c
feat: support redirect url
ClarkXia 087ff45
fix: vite ssr
ClarkXia db63f92
chore: optimize code
ClarkXia 5c6807a
chore: optimize code
ClarkXia e082969
chore: update lock file
ClarkXia b7c52f0
fix: noExternal with miniapp-history
ClarkXia 173d84f
Merge branch 'release/2.5.0' into feat-vite-ssr
ClarkXia cd0abc5
feat: support ssg
ClarkXia ca523a7
Merge branch 'feat-vite-ssr' of github.com:alibaba/ice into feat-vite…
ClarkXia a6724a6
feat: isServer
ClarkXia dd166e1
chore: comment
ClarkXia d35f2c8
chore: rename plugin
ClarkXia 91c2fc3
chore: comment
ClarkXia 6bc9de8
fix: import env file
ClarkXia 35db134
chore: changelog
ClarkXia 39e9e30
chore: ts lint
ClarkXia dc14537
fix: env path
ClarkXia File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
|
@@ -24,4 +24,4 @@ export default { | |
}); | ||
}, | ||
}), | ||
}; | ||
}; |
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,4 @@ | ||
import { createStore } from 'ice'; | ||
import user from './models/user'; | ||
|
||
export default createStore({ user }); | ||
export default createStore({ user }); |
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,4 @@ | ||
{ | ||
"ssr": true, | ||
"vite": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "basic-vite-ssr", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"start": "../../packages/icejs/bin/ice-cli.js start", | ||
"build": "../../packages/icejs/bin/ice-cli.js build" | ||
}, | ||
"dependencies": { | ||
"react": "^17.0.0", | ||
"react-dom": "^17.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0" | ||
}, | ||
"license": "MIT" | ||
} |
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,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="ice-container"></div> | ||
</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,8 @@ | ||
export default ({ children }) => { | ||
return ( | ||
<div> | ||
Layout | ||
{children} | ||
</div> | ||
); | ||
}; |
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 { runApp, IAppConfig } from 'ice'; | ||
|
||
const appConfig: IAppConfig = { | ||
app: { | ||
rootId: 'ice-container', | ||
errorBoundary: true, | ||
}, | ||
router: { | ||
type: 'browser', | ||
}, | ||
}; | ||
|
||
runApp(appConfig); |
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,11 @@ | ||
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; | ||
} |
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 @@ | ||
export default () => { | ||
return ( | ||
<div>Page1</div> | ||
); | ||
}; |
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 @@ | ||
export default () => { | ||
return ( | ||
<div>Page2</div> | ||
); | ||
}; |
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,8 @@ | ||
export default ({ children }) => { | ||
return ( | ||
<div> | ||
这是 Dashboard | ||
{children} | ||
</div> | ||
); | ||
}; |
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,75 @@ | ||
:root { | ||
--primay: black; | ||
--bg-primay: white; | ||
|
||
--link: #2a0b0b; | ||
} | ||
|
||
.App { | ||
text-align: center; | ||
} | ||
|
||
.App-logo { | ||
height: 40vmin; | ||
pointer-events: none; | ||
} | ||
|
||
p { | ||
margin: 20px 0px; | ||
} | ||
|
||
.header { | ||
font-size: 3rem; | ||
} | ||
|
||
.body { | ||
margin: 20px 0 10px; | ||
font-size: 0.9rem; | ||
} | ||
|
||
button { | ||
outline: none; | ||
border: none; | ||
border-radius: 8px; | ||
padding: 10px 35px; | ||
|
||
background: #845ec2; | ||
color: white; | ||
} | ||
|
||
@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); | ||
|
||
background: var(--bg-primay); | ||
color: var(--primay); | ||
} | ||
|
||
.App-link { | ||
color: #61dafb; | ||
color: var(--link); | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
button { | ||
font-size: calc(10px + 2vmin); | ||
} |
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,39 @@ | ||
import { useState } from 'react'; | ||
import './index.css'; | ||
|
||
function App() { | ||
const [count, setCount] = useState<number>(0); | ||
|
||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<div className="body"> | ||
<button type="button" onClick={() => setCount((e) => e + 1)}> | ||
🪂 Click me : {count} | ||
</button> | ||
|
||
<p> Don't forget to install <a href="https://appworks.site/">AppWorks</a> in Your Vscode.</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> | ||
</div> | ||
</header> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
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,39 @@ | ||
import { IRouterConfig } from 'ice'; | ||
import DashboardLayout from '@/pages/Dashboard'; | ||
import Dashboard1 from '@/pages/Dashboard/Page1'; | ||
import Dashboard2 from '@/pages/Dashboard/Page2'; | ||
import Home from '@/pages/Home'; | ||
import Layout from '@/Layout'; | ||
|
||
const routes: IRouterConfig[] = [ | ||
{ | ||
path: '/', | ||
component: Home, | ||
exact: true | ||
}, | ||
{ | ||
path: '/', | ||
component: Layout, | ||
children: [ | ||
{ | ||
path: '/dashboard', | ||
component: DashboardLayout, | ||
children: [ | ||
{ | ||
path: '/a', | ||
component: Dashboard1, | ||
exact: true | ||
}, | ||
{ | ||
path: '/b', | ||
component: Dashboard2, | ||
exact: true | ||
} | ||
] | ||
}, | ||
] | ||
}, | ||
|
||
]; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
declare module '*.module.scss' { | ||
const classes: { [key: string]: string }; | ||
export default classes; | ||
} |
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,44 @@ | ||
{ | ||
"compileOnSave": false, | ||
"buildOnSave": false, | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "build", | ||
"module": "esnext", | ||
"target": "es6", | ||
"jsx": "react-jsx", | ||
"moduleResolution": "node", | ||
"allowSyntheticDefaultImports": true, | ||
"lib": [ | ||
"es6", | ||
"dom" | ||
], | ||
"sourceMap": true, | ||
"allowJs": true, | ||
"rootDir": "./", | ||
"forceConsistentCasingInFileNames": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noImplicitAny": false, | ||
"importHelpers": true, | ||
"strictNullChecks": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true, | ||
"types": ["node", "jest", "vite/client"], | ||
"paths": { | ||
"@/*": [ | ||
"./src/*" | ||
], | ||
"ice": [ | ||
".ice/index.ts" | ||
], | ||
"ice/*": [ | ||
".ice/pages/*" | ||
], | ||
"$store": [ | ||
"src/store1.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
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 |
---|---|---|
|
@@ -52,7 +52,7 @@ export function runApp(appConfig?: IAppConfig) { | |
// set History before GID | ||
initHistory && initHistory(appConfig as any); | ||
<% } %> | ||
if (process.env.__IS_SERVER__) return; | ||
if ((typeof global !== 'undefined' && (global as any).__IS_SERVER__) || process.env.__IS_SERVER__) return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 为什么不复用 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 是不是全部统一到运行时判断:globalThis.IS_SERVER |
||
reactAppRenderer({ | ||
appConfig: appConfig as RenderAppConfig, | ||
buildConfig, | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后面两个多余的