Skip to content

Instantly share code, notes, and snippets.

@ali-master
Created December 22, 2024 00:47
Show Gist options
  • Save ali-master/5d950101780652a7d09968d4c4f45f03 to your computer and use it in GitHub Desktop.
Save ali-master/5d950101780652a7d09968d4c4f45f03 to your computer and use it in GitHub Desktop.
Run Nestjs with Farm bundler
import { defineConfig } from "@farmfe/core";
export default defineConfig({
plugins: [
{
name: "NestJS",
priority: 0,
config(config) {
const inputFileEntry = Object.values(config?.compilation?.input || {})[0] ?? "src/main.ts";
const mode = config.compilation.mode ?? process.env.NODE_ENV ?? "development";
const isDev = mode === "development";
return {
compilation: {
input: {
nest: inputFileEntry,
},
script: {
plugins: [],
target: "es2019",
parser: {
tsConfig: {
decorators: true,
dts: false,
noEarlyErrors: false,
tsx: false,
},
},
decorators: {
legacyDecorator: true,
decoratorMetadata: true,
decoratorVersion: "2022-03",
includes: [inputFileEntry],
excludes: ["node_modules/**/*"],
},
},
presetEnv: !isDev,
minify: !isDev,
clearScreen: true,
external: ["farmhash"],
persistentCache: true,
sourcemap: "inline",
output: {
format: "esm",
targetEnv: "node",
entryFilename: "[entryName].js",
filename: "[name].[hash].mjs",
},
},
};
},
},
],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment