@xfe-repo/web-app 1.6.1 → 1.6.3

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
@@ -1,3 +1,7 @@
1
1
  # `@xfe-repo/web-app`
2
2
 
3
3
  web框架基础库
4
+
5
+ 构建会先加载 `react-app-polyfill/stable`,并在应用原有 browserslist 的基础上,补充 Edge 18、Chrome 64、Firefox 60、Safari/iOS 12 及以上的 JS 编译目标,业务代码和第三方依赖使用同一目标。
6
+
7
+ 这是 JS 兼容基线;具体组件样式和浏览器 Web API 仍需在目标浏览器验证。
@@ -88,6 +88,16 @@ module.exports = function (webpackEnv) {
88
88
  const isEnvDevelopment = webpackEnv === 'development'
89
89
  const isEnvProduction = webpackEnv === 'production'
90
90
 
91
+ // 保留应用声明的目标,补充不随市场占有率淘汰的旧浏览器基线。
92
+ const browserTargets = [
93
+ ...require('browserslist')(undefined, { path: paths.appPath, env: process.env.BROWSERSLIST_ENV || webpackEnv }),
94
+ 'edge >= 18',
95
+ 'chrome >= 64',
96
+ 'firefox >= 60',
97
+ 'safari >= 12',
98
+ 'ios_saf >= 12',
99
+ ]
100
+
91
101
  // Variable used for enabling profiling in Production
92
102
  // passed into alias object. Uses a flag if passed into the build command
93
103
  const isEnvProductionProfile = isEnvProduction && process.argv.includes('--profile')
@@ -185,7 +195,7 @@ module.exports = function (webpackEnv) {
185
195
  }
186
196
 
187
197
  return {
188
- target: ['browserslist'],
198
+ target: `browserslist:${browserTargets.join(',')}`,
189
199
  // Webpack noise constrained to errors and warnings
190
200
  stats: 'errors-warnings',
191
201
  mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development',
@@ -194,7 +204,7 @@ module.exports = function (webpackEnv) {
194
204
  devtool: isEnvProduction ? (shouldUseSourceMap ? 'source-map' : false) : isEnvDevelopment && 'cheap-module-source-map',
195
205
  // These are the "entry points" to our application.
196
206
  // This means they will be the "root" imports that are included in JS bundle.
197
- entry: paths.appIndexJs,
207
+ entry: [require.resolve('react-app-polyfill/stable'), paths.appIndexJs],
198
208
  output: {
199
209
  // The build folder.
200
210
  path: paths.appBuild,
@@ -390,6 +400,7 @@ module.exports = function (webpackEnv) {
390
400
  include: paths.appSrc,
391
401
  loader: require.resolve('babel-loader'),
392
402
  options: {
403
+ targets: browserTargets,
393
404
  customize: require.resolve('babel-preset-react-app/webpack-overrides'),
394
405
  presets: [
395
406
  [
@@ -418,9 +429,11 @@ module.exports = function (webpackEnv) {
418
429
  // Unlike the application JS, we only compile the standard ES features.
419
430
  {
420
431
  test: /\.(js|mjs)$/,
421
- exclude: /@babel(?:\/|\\{1,2})runtime/,
432
+ // 保留完整 polyfill,避免 CRA 按 core-js 3.0 裁掉较新的运行时 API。
433
+ exclude: /@babel(?:\/|\\{1,2})runtime|core-js|react-app-polyfill/,
422
434
  loader: require.resolve('babel-loader'),
423
435
  options: {
436
+ targets: browserTargets,
424
437
  babelrc: false,
425
438
  configFile: false,
426
439
  compact: false,
package/deploy/.drone.yml CHANGED
@@ -138,6 +138,27 @@ steps:
138
138
  include:
139
139
  - refs/tags/release-*
140
140
 
141
+ - name: push-helm-chart
142
+ image: xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image-common/deploy-helm:latest
143
+ environment:
144
+ USERNAME:
145
+ from_secret: username
146
+ PASSWORD:
147
+ from_secret: password
148
+ commands:
149
+ - chartName="${DRONE_REPO//\//-}"
150
+ - chartVersion="0.0.0-$DRONE_TAG"
151
+ - cp deploy/helm/values.prod.yaml deploy/helm/values.yaml
152
+ - sed -i "s/deployment/$chartName/g" deploy/helm/Chart.yaml
153
+ - helm package deploy/helm --version "$chartVersion"
154
+ - set +x
155
+ - printf '%s' "$PASSWORD" | helm registry login xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com --username "$USERNAME" --password-stdin
156
+ - helm push "$chartName-$chartVersion.tgz" oci://xhj-prod-registry-vpc.cn-hangzhou.cr.aliyuncs.com/xhj-image
157
+ when:
158
+ ref:
159
+ include:
160
+ - refs/tags/release-*
161
+
141
162
  volumes:
142
163
  - name: node-modules
143
164
  host:
package/deploy/nginx.conf CHANGED
@@ -5,6 +5,13 @@ server {
5
5
  server_name -;
6
6
  root /code/www/deploy/webroot/app/current;
7
7
 
8
+ gzip on;
9
+ gzip_vary on;
10
+ gzip_proxied any;
11
+ gzip_comp_level 5;
12
+ gzip_min_length 1024;
13
+ gzip_types text/plain text/css text/javascript application/javascript application/json application/xml text/xml image/svg+xml;
14
+
8
15
  set $apiEnv test;
9
16
 
10
17
  if ( $host ~* ^(?<hostPrefix>[^.]+)?\.?(?<subDomain>.*?)\.?(?<domain>[^.]+)\.(?<ltd>[a-zA-Z]+)$ ) {
@@ -23,14 +30,24 @@ server {
23
30
  }
24
31
 
25
32
  location /check-update {
26
- add_header Cache-control no-cache;
33
+ add_header Cache-Control no-cache always;
27
34
 
28
35
  try_files /release =404;
29
36
  }
30
37
 
31
- # 兼容v2版本的静态资源
32
- location /v2/static {
33
- rewrite /v2(.*) $1 break;
38
+ # 仅带内容 hash 的资源使用长期缓存
39
+ location ~* "\.[0-9a-f]{8,}(\.chunk)?\.[^./]+$" {
40
+ rewrite ^/v[0-9]+(/(static|js|css)/.*)$ $1 break;
41
+ try_files $uri =404;
42
+
43
+ add_header 'Access-Control-Allow-Origin' '*';
44
+ add_header Cache-Control "public, max-age=31536000, immutable";
45
+ }
46
+
47
+ # 兼容 /v数字/ 前缀下的构建资源
48
+ location ~ ^/v[0-9]+/(static|js|css)/ {
49
+ rewrite ^/v[0-9]+(/.*)$ $1 break;
50
+ add_header Cache-Control no-cache always;
34
51
  }
35
52
 
36
53
  location / {
@@ -39,7 +56,7 @@ server {
39
56
  # 兼容微前端 允许跨域
40
57
  add_header 'Access-Control-Allow-Origin' '*';
41
58
 
42
- add_header Cache-Control no-cache;
59
+ add_header Cache-Control no-cache always;
43
60
  add_header Set-Cookie "apiEnv=${apiEnv}; Max-Age=2626560; Path=/;";
44
61
  }
45
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-app",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "bin": {
5
5
  "xfe-web": "./bin/index.js"
6
6
  },
@@ -80,7 +80,7 @@
80
80
  "workbox-webpack-plugin": "^7.0.0",
81
81
  "yaml": "^2.3.4",
82
82
  "@xfe-repo/eslint-config": "1.6.0",
83
- "@xfe-repo/typescript-config": "1.6.1"
83
+ "@xfe-repo/typescript-config": "1.6.2"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "react": "18.2.0",