我正在努力构建打字稿 monorepo 的生产版本。我工作的公司有一个包含多个 API (nestJS) 的单声道存储库和一些公共库(主要是使用 tsc 构建的 typescript 源代码),遗憾的是我无法在这里分享。
这些 API 可以使用运行nest start,我们也可以@nestjs/swagger毫无问题地访问 API 中部署的内容。直到几周前,我们还在使用nest build --webpack以下 webpack 配置构建生产工件:
const path = require("path");
const webpack = require("webpack");
module.exports = function (options) {
return {
...options,
mode: "production",
target: "node",
node: {
__dirname: false,
__filename: false
},
entry: "./src/main.ts",
output: {
path: path.resolve(__dirname, "build"),
filename: "main.js",
clean: true
},
externals: [...options.externals, "fastify-swagger"],
module: {
...options.modules,
rules: [
{
test: /\.(t|j)sx?$/,
exclude: /node_modules/,
use: { …Run Code Online (Sandbox Code Playgroud)