diff --git a/client/web/build/webpack.config.ts b/client/web/build/webpack.config.ts index e68edeb5..d4053cbb 100644 --- a/client/web/build/webpack.config.ts +++ b/client/web/build/webpack.config.ts @@ -18,6 +18,7 @@ import { BundleStatsWebpackPlugin } from 'bundle-stats-webpack-plugin'; import { WebpackStatsViewerPlugin } from 'webpack-stats-viewer-plugin'; import { buildWorkboxPlugin } from './workbox'; import { RetryChunkLoadPlugin } from 'webpack-retry-chunk-load-plugin'; +import GenerateJsonPlugin from 'generate-json-webpack-plugin'; // eslint-disable-next-line @typescript-eslint/no-var-requires require('dotenv').config(); @@ -39,6 +40,9 @@ declare module 'webpack' { const NODE_ENV = process.env.NODE_ENV ?? 'production'; const PREF_REPORT = !!process.env.PREF_REPORT; +const VERSION = + process.env.VERSION || `nightly-${dayjs().format('YYYYMMDDHHmm')}`; +const SERVICE_URL = process.env.SERVICE_URL; // 如果不传则为当前服务,用于前后端分离的场景 const isDev = NODE_ENV === 'development'; const mode = isDev ? 'development' : 'production'; @@ -46,10 +50,8 @@ const mode = isDev ? 'development' : 'production'; const plugins: Configuration['plugins'] = [ new DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(NODE_ENV), - 'process.env.SERVICE_URL': JSON.stringify(process.env.SERVICE_URL), - 'process.env.VERSION': JSON.stringify( - process.env.VERSION || `nightly-${dayjs().format('YYYYMMDDHHmm')}` - ), + 'process.env.SERVICE_URL': JSON.stringify(SERVICE_URL), + 'process.env.VERSION': JSON.stringify(VERSION), }), new HtmlWebpackPlugin({ title: 'Tailchat', @@ -91,6 +93,11 @@ const plugins: Configuration['plugins'] = [ }, ], }) as any, + new GenerateJsonPlugin('tailchat.manifest', { + version: VERSION, + env: NODE_ENV, + serviceUrl: SERVICE_URL, + }), new MiniCssExtractPlugin({ filename: 'styles-[contenthash].css' }), new RetryChunkLoadPlugin({ maxRetries: 2, diff --git a/client/web/package.json b/client/web/package.json index 6181b5c8..eb9121b4 100644 --- a/client/web/package.json +++ b/client/web/package.json @@ -38,6 +38,7 @@ "copy-to-clipboard": "^3.3.3", "detect-browser": "^5.3.0", "emoji-mart": "^5.5.2", + "generate-json-webpack-plugin": "^2.0.0", "immer": "^9.0.16", "is-electron": "^2.2.1", "is-hotkey": "^0.2.0", @@ -84,6 +85,7 @@ "@types/copy-webpack-plugin": "^8.0.1", "@types/dts-generator": "^2.1.7", "@types/fs-extra": "^9.0.13", + "@types/generate-json-webpack-plugin": "^0.3.4", "@types/is-hotkey": "^0.1.7", "@types/jest": "^29.2.4", "@types/loadable__component": "^5.13.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 71713a0f..d13a0040 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -346,6 +346,7 @@ importers: '@types/copy-webpack-plugin': ^8.0.1 '@types/dts-generator': ^2.1.7 '@types/fs-extra': ^9.0.13 + '@types/generate-json-webpack-plugin': ^0.3.4 '@types/is-hotkey': ^0.1.7 '@types/jest': ^29.2.4 '@types/loadable__component': ^5.13.4 @@ -387,6 +388,7 @@ importers: execa: ^5.1.1 file-loader: ^6.2.0 fs-extra: ^10.1.0 + generate-json-webpack-plugin: ^2.0.0 glob: ^7.2.3 html-webpack-plugin: ^5.5.0 identity-obj-proxy: ^3.0.0 @@ -471,6 +473,7 @@ importers: copy-to-clipboard: 3.3.3 detect-browser: 5.3.0 emoji-mart: 5.5.2 + generate-json-webpack-plugin: 2.0.0 immer: 9.0.16 is-electron: 2.2.1 is-hotkey: 0.2.0 @@ -516,6 +519,7 @@ importers: '@types/copy-webpack-plugin': 8.0.1_webpack-cli@4.10.0 '@types/dts-generator': 2.1.7 '@types/fs-extra': 9.0.13 + '@types/generate-json-webpack-plugin': 0.3.4 '@types/is-hotkey': 0.1.7 '@types/jest': 29.2.4 '@types/loadable__component': 5.13.4 @@ -7240,7 +7244,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.5.1 - '@types/node': 18.11.16 + '@types/node': 18.11.18 chalk: 4.1.2 jest-message-util: 27.5.1 jest-util: 27.5.1 @@ -7351,7 +7355,7 @@ packages: '@jest/test-result': 27.5.1 '@jest/transform': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 18.11.16 + '@types/node': 18.11.18 chalk: 4.1.2 collect-v8-coverage: 1.0.1 exit: 0.1.2 @@ -7518,7 +7522,7 @@ packages: '@jest/schemas': 29.0.0 '@types/istanbul-lib-coverage': 2.0.4 '@types/istanbul-reports': 3.0.1 - '@types/node': 18.11.16 + '@types/node': 18.11.18 '@types/yargs': 17.0.17 chalk: 4.1.2 dev: true @@ -12717,12 +12721,12 @@ packages: resolution: {integrity: sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==} dependencies: '@types/connect': 3.4.35 - '@types/node': 18.11.16 + '@types/node': 18.11.18 /@types/bonjour/3.5.10: resolution: {integrity: sha512-p7ienRMiS41Nu2/igbJxxLDWrSZ0WxM8UQgCeO9KhoVF7cOVFkrKsiDr1EsJIla8vV3oEEjGcz11jc5yimhzZw==} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 /@types/btoa-lite/1.0.0: resolution: {integrity: sha512-wJsiX1tosQ+J5+bY5LrSahHxr2wT+uME5UDwdN1kg4frt40euqA+wzECkmq4t5QbveHiJepfdThgQrPw6KiSlg==} @@ -12760,12 +12764,12 @@ packages: resolution: {integrity: sha512-h8QJa8xSb1WD4fpKBDcATDNGXghFj6/3GRWG6dhmRcu0RX1Ubasur2Uvx5aeEwlf0MwblEC2bMzzMQntxnw/Cw==} dependencies: '@types/express-serve-static-core': 4.17.31 - '@types/node': 18.11.16 + '@types/node': 18.11.18 /@types/connect/3.4.35: resolution: {integrity: sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 /@types/content-disposition/0.5.5: resolution: {integrity: sha512-v6LCdKfK6BwcqMo+wYW05rLS12S0ZO0Fl4w1h4aaZMD7bqT3gVUns6FvLJKGZHQmYn3SX55JWGpziwJRwVgutA==} @@ -12921,7 +12925,7 @@ packages: /@types/express-serve-static-core/4.17.31: resolution: {integrity: sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 '@types/qs': 6.9.7 '@types/range-parser': 1.2.4 @@ -12961,11 +12965,17 @@ packages: dependencies: '@types/node': 18.11.16 + /@types/generate-json-webpack-plugin/0.3.4: + resolution: {integrity: sha512-MubuE9xfB/NYIDGsmDs6O5nw6SDRmiUMAIWEfDHng1gQoI6w0/Zaa0CPTWIQ3OoiE9Z988q4R4Vsog4r6gXFvg==} + dependencies: + '@types/webpack': 4.41.32 + dev: true + /@types/glob/7.2.0: resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} dependencies: '@types/minimatch': 3.0.5 - '@types/node': 18.11.16 + '@types/node': 18.11.18 /@types/glob/8.0.0: resolution: {integrity: sha512-l6NQsDDyQUVeoTynNpC9uRvCUint/gSUXQA2euwmTuWGvPY5LSDUu6tkCtJB2SvGQlJQzLaKqcGZP4//7EDveA==} @@ -12977,7 +12987,7 @@ packages: /@types/graceful-fs/4.1.5: resolution: {integrity: sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 dev: true /@types/hast/2.3.4: @@ -13013,7 +13023,7 @@ packages: /@types/http-proxy/1.17.9: resolution: {integrity: sha512-QsbSjA/fSk7xB+UXlCT3wHBy5ai9wOcNDWwZAtud+jXhwOM3l+EYZh8Lng4+/6n8uar0J7xILzqftJdJ/Wdfkw==} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 /@types/i18next-fs-backend/1.1.2: resolution: {integrity: sha512-ZzTRXA5B0x0oGhzKNp08IsYjZpli4LjRZpg3q4j0XFxN5lKG2MVLnR4yHX8PPExBk4sj9Yfk1z9O6CjPrAlmIQ==} @@ -13567,7 +13577,7 @@ packages: /@types/resolve/1.17.1: resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 /@types/responselike/1.0.0: resolution: {integrity: sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==} @@ -13602,12 +13612,12 @@ packages: resolution: {integrity: sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==} dependencies: '@types/mime': 3.0.1 - '@types/node': 18.11.16 + '@types/node': 18.11.18 /@types/sockjs/0.3.33: resolution: {integrity: sha512-f0KEEe05NvUnat+boPTZ0dgaLZ4SfSouXUgv5noUiefG2ajgKjmETo9ZJyuqsl7dfl2aHlLJUiki6B4ZYldiiw==} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 /@types/source-list-map/0.1.2: resolution: {integrity: sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==} @@ -13733,7 +13743,7 @@ packages: /@types/webpack-sources/3.2.0: resolution: {integrity: sha512-Ft7YH3lEVRQ6ls8k4Ff1oB4jN6oy/XmU6tQISKdhfh+1mR+viZFphS6WL0IrtDOzvefmJg5a0s7ZQoRXwqTEFg==} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 '@types/source-list-map': 0.1.2 source-map: 0.7.4 dev: true @@ -13741,7 +13751,7 @@ packages: /@types/webpack/4.41.32: resolution: {integrity: sha512-cb+0ioil/7oz5//7tZUSwbrSAN/NWHrQylz5cW8G0dWTcF/g+/dSdMlKVZspBYuMAN1+WnwHrkxiRrLcwd0Heg==} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 '@types/tapable': 1.0.8 '@types/uglify-js': 3.17.0 '@types/webpack-sources': 3.2.0 @@ -13771,7 +13781,7 @@ packages: /@types/ws/8.5.3: resolution: {integrity: sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 /@types/yargs-parser/21.0.0: resolution: {integrity: sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==} @@ -15703,7 +15713,7 @@ packages: babel-plugin-syntax-jsx: 6.18.0 lodash: 4.17.21 picomatch: 2.3.1 - styled-components: 5.3.6_react@18.2.0 + styled-components: 5.3.6_7i5myeigehqah43i5u7wbekgba /babel-plugin-syntax-jsx/6.18.0: resolution: {integrity: sha512-qrPaCSo9c8RHNRHIotaufGbuOBN8rtdC4QrrFFc43vyWCCz7Kl7GL1PGaXtMGQZUXrkCjNEgxDfmAuAabr/rlw==} @@ -21805,6 +21815,10 @@ packages: wide-align: 1.1.5 dev: true + /generate-json-webpack-plugin/2.0.0: + resolution: {integrity: sha512-WVEHXiES7YwjLAjWquC5+IspZM4Pwtx1yHlHTBXHkp38HVjnHJo29PxLniWPSyiB539iDgeAcMNUBStrixx3Jw==} + dev: false + /genshin-gacha-kit/1.1.0: resolution: {integrity: sha512-xQ2tRLjSzcGD5FA2RTJZ35oDjenuvJr+eBvvet6TN9dkedLDydYqq73hVshRXvaYcVqUKbX543MvxYBAVEhD+A==} dependencies: @@ -24352,7 +24366,7 @@ packages: '@jest/environment': 27.5.1 '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 18.11.16 + '@types/node': 18.11.18 chalk: 4.1.2 co: 4.6.0 dedent: 0.7.0 @@ -24435,7 +24449,7 @@ packages: pretty-format: 27.5.1 slash: 3.0.0 strip-json-comments: 3.1.1 - ts-node: 10.9.1_t4lrjbt3sxauai4t5o275zsepa + ts-node: 10.9.1_nzafxra4mdyuer2ejmql6rdadq transitivePeerDependencies: - bufferutil - canvas @@ -24526,7 +24540,7 @@ packages: '@jest/environment': 27.5.1 '@jest/fake-timers': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 18.11.16 + '@types/node': 18.11.18 jest-mock: 27.5.1 jest-util: 27.5.1 dev: true @@ -24580,7 +24594,7 @@ packages: dependencies: '@jest/types': 27.5.1 '@types/graceful-fs': 4.1.5 - '@types/node': 18.11.16 + '@types/node': 18.11.18 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.10 @@ -24602,7 +24616,7 @@ packages: '@jest/source-map': 27.5.1 '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 18.11.16 + '@types/node': 18.11.18 chalk: 4.1.2 co: 4.6.0 expect: 27.5.1 @@ -24768,7 +24782,7 @@ packages: '@jest/test-result': 27.5.1 '@jest/transform': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 18.11.16 + '@types/node': 18.11.18 chalk: 4.1.2 emittery: 0.8.1 graceful-fs: 4.2.10 @@ -24833,7 +24847,7 @@ packages: resolution: {integrity: sha512-jZCyo6iIxO1aqUxpuBlwTDMkzOAJS4a3eYz3YzgxxVQFwLeSA7Jfq5cbqCY+JLvTDrWirgusI/0KwxKMgrdf7w==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 graceful-fs: 4.2.10 dev: true @@ -24920,7 +24934,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.3.1 - '@types/node': 18.11.16 + '@types/node': 18.11.18 chalk: 4.1.2 ci-info: 3.7.0 graceful-fs: 4.2.10 @@ -24945,7 +24959,7 @@ packages: dependencies: '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 - '@types/node': 18.11.16 + '@types/node': 18.11.18 ansi-escapes: 4.3.2 chalk: 4.1.2 jest-util: 27.5.1 @@ -24956,7 +24970,7 @@ packages: resolution: {integrity: sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 merge-stream: 2.0.0 supports-color: 7.2.0 @@ -24964,7 +24978,7 @@ packages: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 18.11.16 + '@types/node': 18.11.18 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -35910,7 +35924,6 @@ packages: react-is: 18.2.0 shallowequal: 1.1.0 supports-color: 5.5.0 - dev: false /styled-components/5.3.6_mdz3marskokvq6744hhidi3r5a: resolution: {integrity: sha512-hGTZquGAaTqhGWldX7hhfzjnIYBZ0IXQXkCYdvF1Sq3DsUaLx6+NTHC5Jj1ooM2F68sBiVz3lvhfwQs/S3l6qg==} @@ -35956,6 +35969,7 @@ packages: react: 18.2.0 shallowequal: 1.1.0 supports-color: 5.5.0 + dev: true /styled-system/5.1.5: resolution: {integrity: sha512-7VoD0o2R3RKzOzPK0jYrVnS8iJdfkKsQJNiLRDjikOpQVqQHns/DXWaPZOH4tIKkhAT7I6wIsy9FWTWh2X3q+A==} @@ -37238,6 +37252,7 @@ packages: typescript: 4.7.4 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 + dev: false /ts-node/10.9.1_typescript@4.7.4: resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==}