-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.plugin.ts
50 lines (47 loc) · 1.39 KB
/
index.plugin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import type { Config } from "@farmfe/core/binding";
export default function NestPlugin(options?: Config['config']) {
// not support multiple input files in nestjs we just need to use one input file first one
const inputFileEntry = Object.values(options?.input || {})[0] ?? 'src/main.ts';
return {
name: 'NestPlugin',
config: (config) => {
const mode = config.compilation.mode ?? process.env.NODE_ENV ?? 'development';
const isDev = mode === 'development';
return {
compilation: {
input: {
'NestJs': inputFileEntry,
},
script: {
plugins: [],
target: 'es2019',
parser: {
tsConfig: {
decorators: true,
dts: false,
noEarlyErrors: false,
tsx: false,
},
},
decorators: {
legacyDecorator: true,
decoratorMetadata: true,
decoratorVersion: '2021-12',
includes: [inputFileEntry],
excludes: ['node_modules/**/*'],
},
},
presetEnv: !isDev,
minify: !isDev,
output: {
format: 'esm',
targetEnv: 'node',
entryFilename: '[entryName].js',
filename: '[name].[hash].mjs',
},
...options
}
}
}
};
}