nsbp-cli 0.2.47 → 0.2.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -147,7 +147,7 @@ node ./bin/nsbp.js --help # Test CLI locally
147
147
 
148
148
  - **Package Name**: `nsbp-cli`
149
149
  - **Bin Command**: `nsbp` (install globally and run `nsbp --help`)
150
- - **Version**: `0.2.47`
150
+ - **Version**: `0.2.49`
151
151
  - **Dependencies**: chalk, commander, fs-extra, inquirer
152
152
  - **Package Manager**: Uses pnpm (also compatible with npm)
153
153
  - **Node Version**: >=16.0.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nsbp-cli",
3
- "version": "0.2.47",
3
+ "version": "0.2.49",
4
4
  "description": "CLI tool for creating NSBP (Node React SSR by Webpack) projects",
5
5
  "main": "index.js",
6
6
  "homepage": "https://nsbp.erishen.cn/",
@@ -9,7 +9,7 @@
9
9
  "dev:init": "cross-env INIT=1 webpack --config config/webpack.server.js --mode development",
10
10
  "dev:build:server": "webpack --config config/webpack.server.js --mode development --watch",
11
11
  "dev:build:client": "webpack --config config/webpack.client.js --mode development --watch",
12
- "dev:build:start": "node ./scripts/start.js",
12
+ "dev:build:start": "nodemon --watch build --ext js --exec \"node ./scripts/start.js\"",
13
13
  "build": "pnpm run clean && npm-run-all -l -p build:**",
14
14
  "build:server": "webpack --config config/webpack.server.js --mode production",
15
15
  "build:client": "webpack --config config/webpack.client.js --mode production",
@@ -51,13 +51,22 @@ app.use(
51
51
  express.static('public', {
52
52
  dotfiles: 'ignore',
53
53
  setHeaders: (res, filePath) => {
54
- // Cache static assets for 1 year
54
+ // 开发环境使用较短的缓存时间,避免代码更新后浏览器使用旧缓存
55
+ // 生产环境使用 1 年缓存(配合 hash 文件名)
56
+ const isDev = process.env.NODE_ENV !== 'production'
57
+
55
58
  if (
56
59
  filePath.match(
57
60
  /\.(js|css|png|jpg|jpeg|gif|svg|ico|woff|woff2|ttf|eot)$/
58
61
  )
59
62
  ) {
60
- res.setHeader('Cache-Control', 'public, max-age=31536000, immutable')
63
+ if (isDev) {
64
+ // 开发环境:缓存 1 小时,便于开发调试
65
+ res.setHeader('Cache-Control', 'public, max-age=3600')
66
+ } else {
67
+ // 生产环境:缓存 1 年(配合 webpack 的 contenthash)
68
+ res.setHeader('Cache-Control', 'public, max-age=31536000, immutable')
69
+ }
61
70
  }
62
71
  }
63
72
  })
@@ -15,7 +15,7 @@ import { ChunkExtractor } from '@loadable/server'
15
15
 
16
16
  interface Request {
17
17
  path: string
18
- query: Record<string, string | undefined>
18
+ query: Record<string, string | string[] | ParsedQs | undefined>
19
19
  }
20
20
 
21
21
  interface Response {