Skip to content

Commit f72fda4

Browse files
fix & doc
1 parent acfbe39 commit f72fda4

File tree

10 files changed

+165
-166
lines changed

10 files changed

+165
-166
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ PROD_PORT=5000
55
PROD_HOST=localhost
66
PUBLIC_API_HOST=localhost:9000
77
CRYPTO_KEY=ad$cr3efW89ypg
8-
SSR=true
8+
SSR=false
99
UI=chakra
10-
MIDDLEWARE=false
10+
MIDDLEWARE=true
1111
ANIMATE_ROUTER=false
1212
SERVER_ENTRY=./src/server/entry.ts
1313
CLIENT_ENTRY=./src/client/entry.tsx

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "./script/start-dev",
88
"dev:csr": "cross-env CSR=true ./script/start-dev",
99
"build": "./script/start-prod",
10-
"lint": "eslint --ext ts,tsx .",
10+
"lint": "eslint --cache --ext ts,tsx .",
1111
"lint:fix": "yarn run lint --fix",
1212
"build:csr": "cross-env CSR=true ./script/start-prod",
1313
"start": "cross-env NODE_ENV=production node ./dist/server/app"
@@ -77,7 +77,7 @@
7777
"@types/loadable__server": "^5.12.3",
7878
"@types/lodash": "^4.14.178",
7979
"@types/multer": "^1.4.7",
80-
"@types/node": "^17.0.12",
80+
"@types/node": "^17.0.13",
8181
"@types/react": "^17.0.38",
8282
"@types/react-dom": "^17.0.11",
8383
"@types/react-redux": "^7.1.22",

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ yarn run start
5454

5555
## 静态路由
5656

57-
## 文件路由 自动 query 参数支持 使用 :参数名(:id.tsx) 文件作为的约定 开发环境支持 page 新建删除的实时路由更新(middleware 模式下支持)
57+
## 文件路由 自动 query 参数支持 使用 :参数名(:id.tsx) 文件作为的约定 开发环境支持 page 新建删除的实时路由更新(middleware 模式下支持, 加载一次后删除会出错)
5858

5959
## 装饰器
6060

@@ -76,4 +76,4 @@ yarn run start
7676

7777
## 开箱既支持多种 UI 组件库(CSR / SSR) 通过环境变量 UI 切换(antd,material,chakra-ui,...)
7878

79-
## TODO support swc-loader
79+
## TODO support swc-loader jest

script/startDevServer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const webpackDevServer = require("webpack-dev-server");
1111
const startDevServer = (clientCompiler, clientConfig) => {
1212
const devServer = new webpackDevServer(clientConfig.devServer, clientCompiler);
1313

14+
devServer.staticWatchers.forEach((v) => {
15+
console.log(v.getWatched());
16+
});
17+
1418
devServer.startCallback(() => console.log(chalk.cyan("🚀 Starting the development node server, please wait....\n")));
1519

1620
return devServer;

src/client/entry.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
import { loadableReady } from "@loadable/component";
33
import { hydrate, render } from "react-dom";
44

5-
import { allRoutes } from "router/routes";
65
import { createUniversalStore } from "store";
76
import { log } from "utils/log";
8-
import { preLoad, preLoadLang } from "utils/preLoad";
97
import { safeData } from "utils/safeData";
108

119
import type { StoreState } from "types/store";
@@ -52,6 +50,8 @@ if (__UI__ === "material") {
5250

5351
if (__CSR__) {
5452
log("pure render by client", "warn");
53+
const { allRoutes } = require("router/routes");
54+
const { preLoad, preLoadLang } = require("utils/preLoad");
5555
Promise.all([preLoadLang({ store, lang: window.__ENV__.LANG }), preLoad(allRoutes, location.pathname, store)]).then(() =>
5656
loadableReady(() => render(<Root store={store} />, place))
5757
);

src/components/chakraComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function ChakraComponent() {
1212
<option value="option2">Option 2</option>
1313
<option value="option3">Option 3</option>
1414
</Select>
15-
<Text color="text">color mode!!</Text>
15+
<Text color="text">color mode!! css variable</Text>
1616
<hr />
1717
<Button onClick={onToggle}>Click Me</Button>
1818
<Fade in={isOpen}>

src/hooks/useHydrate.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import type { UseHydrate } from "types/hooks";
66

77
const useHydrate: UseHydrate = ({ routes, pathName }) => {
88
useMemo(() => {
9-
hydrateLoad(routes, pathName);
10-
// eslint-disable-next-line react-hooks/exhaustive-deps
9+
if (!__CSR__) {
10+
hydrateLoad(routes, pathName);
11+
}
12+
// eslint-disable-next-line react-hooks/exhaustive-deps
1113
}, []);
1214
};
1315

src/theme/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export const theme = extendTheme({
77
// 根据data-theme进行响应 不需要进行其他js计算
88
text: {
99
default: "gray.900",
10-
_dark: "gray.50",
10+
_light: "blue.600",
11+
_dark: "red.500",
1112
},
1213
},
1314
},

webpack/devServer.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const path = require("path");
21
const WebpackDevServer = require("webpack-dev-server");
32

43
/**
@@ -24,13 +23,6 @@ const devServerConfig = ({ publicPath }) => {
2423
static: {
2524
publicPath,
2625
},
27-
watchFiles: {
28-
// TODO look like not work, need more work for this
29-
paths: [path.resolve(process.cwd(), "src"), path.resolve(process.cwd(), "webpack"), path.resolve(process.cwd(), "script")],
30-
options: {
31-
ignored: ["**/node_modules/**", "**/router/dynamicRoutes.ts", "**/server/**"],
32-
},
33-
},
3426
devMiddleware: {
3527
publicPath,
3628
writeToDisk: (filepath) => filepath.includes("manifest-loadable.json") || filepath.includes("manifest-dev.json"),

0 commit comments

Comments
 (0)