From 4a3252a710819abb56ffba72562c198d48dfff8e Mon Sep 17 00:00:00 2001 From: Kuizuo Date: Fri, 10 Nov 2023 01:26:05 +0800 Subject: [PATCH] chore(api): remove webpack --- apps/api/ecosystem.config.js | 38 ++--- apps/api/package.json | 7 +- apps/api/webpack-hmr.config.js | 29 ---- pnpm-lock.yaml | 285 +-------------------------------- 4 files changed, 17 insertions(+), 342 deletions(-) delete mode 100644 apps/api/webpack-hmr.config.js diff --git a/apps/api/ecosystem.config.js b/apps/api/ecosystem.config.js index 62e15ae..bb3c2a2 100644 --- a/apps/api/ecosystem.config.js +++ b/apps/api/ecosystem.config.js @@ -1,33 +1,21 @@ +const { cpus } = require('os'); + +const cpuLen = cpus().length; + module.exports = { apps: [ { - name: 'kz-admin', // 项目名字,启动后的名字 - script: './dist/main.js', // 执行的文件 - cwd: './', // 根目录 - args: '', // 传递给脚本的参数 - watch: true, // 开启监听文件变动重启 - ignore_watch: ['node_modules', 'public', 'logs'], // 不用监听的文件 - instances: '1', // max表示最大的 应用启动实例个数,仅在 cluster 模式有效 默认为 fork - autorestart: true, // 默认为 true, 发生异常的情况下自动重启 - max_memory_restart: '1G', - error_file: './logs/app-err.log', // 错误日志文件 - out_file: './logs/app-out.log', // 正常日志文件 - merge_logs: true, // 设置追加日志而不是新建日志 - log_date_format: 'YYYY-MM-DD HH:mm:ss', // 指定日志文件的时间格式 - min_uptime: '60s', // 应用运行少于时间被认为是异常启动 - max_restarts: 30, // 最大异常重启次数 - restart_delay: 60, // 异常重启情况下,延时重启时间 + name: 'nest-admin', + script: 'index.js', + autorestart: true, + exec_mode: 'cluster', + watch: false, + instances: cpuLen, + max_memory_restart: '520M', + args: '', env: { - NODE_ENV: 'development', - }, - env_development: { - NODE_ENV: 'development', - }, - env_production: { NODE_ENV: 'production', - }, - env_test: { - NODE_ENV: 'test', + PORT: process.env.APP_PORT, }, }, ], diff --git a/apps/api/package.json b/apps/api/package.json index 2721b1b..c6be334 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -12,7 +12,6 @@ "start": "NODE_ENV=development nest start", "start:prod": "NODE_ENV=production node dist/main", "dev": "NODE_ENV=development nest start --watch", - "dev:hmr": "NODE_ENV=development nest build --webpack --webpackPath webpack-hmr.config.js --watch", "dev:debug": "NODE_ENV=development nest start --debug --watch", "pm2:prod": "pm2 start ecosystem.config.js --env production", "pm2:dev": "pm2 start ecosystem.config.js --env development", @@ -98,7 +97,6 @@ "@types/node": "^20.9.0", "@types/supertest": "^2.0.16", "@types/ua-parser-js": "^0.7.39", - "@types/webpack-env": "^1.18.4", "@typescript-eslint/eslint-plugin": "^6.10.0", "@typescript-eslint/parser": "^6.10.0", "eslint": "^8.53.0", @@ -110,16 +108,13 @@ "eslint-plugin-unused-imports": "^3.0.0", "jest": "^29.7.0", "prettier": "^3.0.3", - "run-script-webpack-plugin": "^0.2.0", "source-map-support": "^0.5.21", "supertest": "^6.3.3", "ts-jest": "^29.1.1", "ts-loader": "^9.5.0", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", - "typescript": "^5.2.2", - "webpack": "^5.89.0", - "webpack-node-externals": "^3.0.0" + "typescript": "^5.2.2" }, "jest": { "moduleFileExtensions": [ diff --git a/apps/api/webpack-hmr.config.js b/apps/api/webpack-hmr.config.js deleted file mode 100644 index 5368bf1..0000000 --- a/apps/api/webpack-hmr.config.js +++ /dev/null @@ -1,29 +0,0 @@ -const nodeExternals = require('webpack-node-externals'); -const { RunScriptWebpackPlugin } = require('run-script-webpack-plugin'); -const path = require('path'); - -module.exports = function (options, webpack) { - const entryFile = 'main.hmr'; - const allowlist = ['webpack/hot/poll?100']; - - return { - ...options, - entry: [...allowlist, `./src/${entryFile}.ts`], - externals: [nodeExternals({ allowlist })], - plugins: [ - ...options.plugins, - new webpack.HotModuleReplacementPlugin(), - new webpack.WatchIgnorePlugin({ - paths: [/\.js$/, /\.d\.ts$/], - }), - new RunScriptWebpackPlugin({ - name: `${entryFile}.js`, - autoRestart: true, - }), - ], - output: { - path: path.join(__dirname, 'dist'), - filename: `${entryFile}.js`, - }, - }; -}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index af428bc..c2e5acd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -237,9 +237,6 @@ importers: vite: specifier: ^4.5.0 version: 4.5.0(@types/node@18.18.9) - vite-plugin-mock: - specifier: ^3.0.0 - version: 3.0.0(esbuild@0.19.5)(mockjs@1.1.0)(vite@4.5.0) vue-tsc: specifier: ^1.8.22 version: 1.8.22(typescript@5.2.2) @@ -653,9 +650,6 @@ importers: vite-plugin-html: specifier: ^3.2.0 version: 3.2.0(vite@4.5.0) - vite-plugin-mock: - specifier: ^2.9.6 - version: 2.9.8(mockjs@1.1.0)(vite@4.5.0) vite-plugin-purge-icons: specifier: ^0.9.2 version: 0.9.2(vite@4.5.0) @@ -2626,15 +2620,6 @@ packages: dev: true optional: true - /@esbuild/linux-loong64@0.14.54: - resolution: {integrity: sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw==} - engines: {node: '>=12'} - cpu: [loong64] - os: [linux] - requiresBuild: true - dev: true - optional: true - /@esbuild/linux-loong64@0.18.20: resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==} engines: {node: '>=12'} @@ -6593,16 +6578,6 @@ packages: run-applescript: 5.0.0 dev: true - /bundle-require@4.0.2(esbuild@0.19.5): - resolution: {integrity: sha512-jwzPOChofl67PSTW2SGubV9HBQAhhR2i6nskiOThauo9dzwDUgOWQScFVaJkjEfYX+UXiD+LEx8EblQMc2wIag==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - peerDependencies: - esbuild: '>=0.17' - dependencies: - esbuild: 0.19.5 - load-tsconfig: 0.2.5 - dev: true - /bytes@3.1.2: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} engines: {node: '>= 0.8'} @@ -7055,6 +7030,7 @@ packages: /commander@11.0.0: resolution: {integrity: sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==} engines: {node: '>=16'} + dev: false /commander@11.1.0: resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==} @@ -8353,215 +8329,6 @@ packages: ext: 1.7.0 dev: true - /esbuild-android-64@0.14.54: - resolution: {integrity: sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [android] - requiresBuild: true - dev: true - optional: true - - /esbuild-android-arm64@0.14.54: - resolution: {integrity: sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: true - optional: true - - /esbuild-darwin-64@0.14.54: - resolution: {integrity: sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug==} - engines: {node: '>=12'} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /esbuild-darwin-arm64@0.14.54: - resolution: {integrity: sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw==} - engines: {node: '>=12'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /esbuild-freebsd-64@0.14.54: - resolution: {integrity: sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg==} - engines: {node: '>=12'} - cpu: [x64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - - /esbuild-freebsd-arm64@0.14.54: - resolution: {integrity: sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q==} - engines: {node: '>=12'} - cpu: [arm64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-32@0.14.54: - resolution: {integrity: sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw==} - engines: {node: '>=12'} - cpu: [ia32] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-64@0.14.54: - resolution: {integrity: sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg==} - engines: {node: '>=12'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-arm64@0.14.54: - resolution: {integrity: sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig==} - engines: {node: '>=12'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-arm@0.14.54: - resolution: {integrity: sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw==} - engines: {node: '>=12'} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-mips64le@0.14.54: - resolution: {integrity: sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw==} - engines: {node: '>=12'} - cpu: [mips64el] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-ppc64le@0.14.54: - resolution: {integrity: sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-riscv64@0.14.54: - resolution: {integrity: sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg==} - engines: {node: '>=12'} - cpu: [riscv64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-linux-s390x@0.14.54: - resolution: {integrity: sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA==} - engines: {node: '>=12'} - cpu: [s390x] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /esbuild-netbsd-64@0.14.54: - resolution: {integrity: sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w==} - engines: {node: '>=12'} - cpu: [x64] - os: [netbsd] - requiresBuild: true - dev: true - optional: true - - /esbuild-openbsd-64@0.14.54: - resolution: {integrity: sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw==} - engines: {node: '>=12'} - cpu: [x64] - os: [openbsd] - requiresBuild: true - dev: true - optional: true - - /esbuild-sunos-64@0.14.54: - resolution: {integrity: sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw==} - engines: {node: '>=12'} - cpu: [x64] - os: [sunos] - requiresBuild: true - dev: true - optional: true - - /esbuild-windows-32@0.14.54: - resolution: {integrity: sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w==} - engines: {node: '>=12'} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /esbuild-windows-64@0.14.54: - resolution: {integrity: sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /esbuild-windows-arm64@0.14.54: - resolution: {integrity: sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /esbuild@0.14.54: - resolution: {integrity: sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==} - engines: {node: '>=12'} - hasBin: true - requiresBuild: true - optionalDependencies: - '@esbuild/linux-loong64': 0.14.54 - esbuild-android-64: 0.14.54 - esbuild-android-arm64: 0.14.54 - esbuild-darwin-64: 0.14.54 - esbuild-darwin-arm64: 0.14.54 - esbuild-freebsd-64: 0.14.54 - esbuild-freebsd-arm64: 0.14.54 - esbuild-linux-32: 0.14.54 - esbuild-linux-64: 0.14.54 - esbuild-linux-arm: 0.14.54 - esbuild-linux-arm64: 0.14.54 - esbuild-linux-mips64le: 0.14.54 - esbuild-linux-ppc64le: 0.14.54 - esbuild-linux-riscv64: 0.14.54 - esbuild-linux-s390x: 0.14.54 - esbuild-netbsd-64: 0.14.54 - esbuild-openbsd-64: 0.14.54 - esbuild-sunos-64: 0.14.54 - esbuild-windows-32: 0.14.54 - esbuild-windows-64: 0.14.54 - esbuild-windows-arm64: 0.14.54 - dev: true - /esbuild@0.18.20: resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==} engines: {node: '>=12'} @@ -12397,11 +12164,6 @@ packages: resolution: {integrity: sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ==} dev: false - /load-tsconfig@0.2.5: - resolution: {integrity: sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dev: true - /loader-runner@4.3.0: resolution: {integrity: sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==} engines: {node: '>=6.11.5'} @@ -13444,6 +13206,7 @@ packages: hasBin: true dependencies: commander: 11.0.0 + dev: false /moment@2.29.4: resolution: {integrity: sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==} @@ -14237,6 +14000,7 @@ packages: /path-to-regexp@6.2.1: resolution: {integrity: sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw==} + dev: false /path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} @@ -17752,49 +17516,6 @@ packages: vite: 4.5.0(less@4.2.0)(sass@1.69.5) dev: true - /vite-plugin-mock@2.9.8(mockjs@1.1.0)(vite@4.5.0): - resolution: {integrity: sha512-YTQM5Sn7t+/DNOwTkr+W26QGTCk1PrDkhGHslTJ90lIPJhJtDTwuSkEYMAuLP9TcVQ/qExTFx/x/GE3kxJ05sw==} - engines: {node: '>=12.0.0'} - peerDependencies: - mockjs: '>=1.1.0' - vite: '>=2.0.0' - dependencies: - '@types/mockjs': 1.0.10 - chalk: 4.1.2 - chokidar: 3.5.3 - connect: 3.7.0 - debug: 4.3.4 - esbuild: 0.14.54 - fast-glob: 3.3.1 - mockjs: 1.1.0 - path-to-regexp: 6.2.1 - vite: 4.5.0(less@4.2.0)(sass@1.69.5) - transitivePeerDependencies: - - supports-color - dev: true - - /vite-plugin-mock@3.0.0(esbuild@0.19.5)(mockjs@1.1.0)(vite@4.5.0): - resolution: {integrity: sha512-Ibwlga2CSgkoFHFtPW3T/l0fwsGVz9Ss5i7HauBQDyDFfMKgbQXh9wKDLksLZHyai9rkDanxJtIcxbD0bUHCfw==} - engines: {node: '>=16.0.0'} - peerDependencies: - mockjs: '>=1.1.0' - vite: '>=4.0.0' - dependencies: - '@types/mockjs': 1.0.10 - bundle-require: 4.0.2(esbuild@0.19.5) - chokidar: 3.5.3 - connect: 3.7.0 - debug: 4.3.4 - fast-glob: 3.3.1 - mockjs: 1.1.0 - path-to-regexp: 6.2.1 - picocolors: 1.0.0 - vite: 4.5.0(@types/node@18.18.9) - transitivePeerDependencies: - - esbuild - - supports-color - dev: true - /vite-plugin-purge-icons@0.9.2(vite@4.5.0): resolution: {integrity: sha512-vxJEMyNyckqLr/4HPsW9P6BMLUvOVMvjjFz3jLl4Wke1KWE8ITJUxIUwodxaOmEp9L2lxVk5an3TYeycZCfqFw==} engines: {node: '>= 12'}