This repository was archived by the owner on Nov 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.plugin.ts
More file actions
48 lines (46 loc) · 1.7 KB
/
index.plugin.ts
File metadata and controls
48 lines (46 loc) · 1.7 KB
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
import { JsPlugin } from '@farmfe/core';
export default function NestPlugin(): JsPlugin {
return {
name: 'NestPlugin',
config: (config) => {
const mode =
config.compilation.mode ?? process.env.NODE_ENV ?? 'development';
const isDev = mode === 'development';
const compilation = config.compilation ?? {};
const script = compilation.script ?? { plugins: [] };
return {
compilation: {
script: {
plugins: script.plugins,
target: script.target ?? 'es2019',
parser: {
tsConfig: {
decorators: script.parser?.tsConfig?.decorators ?? true,
dts: script.parser?.tsConfig?.dts ?? false,
noEarlyErrors: script.parser?.tsConfig?.noEarlyErrors ?? false,
tsx: script.parser?.tsConfig?.tsx ?? false,
},
},
decorators: {
legacyDecorator: script.decorators?.legacyDecorator ?? true,
decoratorMetadata: script.decorators?.decoratorMetadata ?? true,
decoratorVersion:
script.decorators?.decoratorVersion ?? '2021-12',
includes: [],
excludes: ['node_modules/**/*'],
},
},
presetEnv: compilation.presetEnv ?? !isDev,
minify: compilation.minify ?? !isDev,
output: {
format: compilation.output?.format ?? 'esm',
targetEnv: compilation.output?.targetEnv ?? 'node',
entryFilename:
compilation.output?.entryFilename ?? '[entryName].js',
filename: compilation.output?.filename ?? '[name].[hash].mjs',
},
},
};
},
};
}