-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.ts
executable file
·39 lines (35 loc) · 1.04 KB
/
webpack.config.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
const webpack = require('webpack');
module.exports = (config, context) => {
const resultConfig = {
...config,
};
const rules = resultConfig.module.rules;
const tsLoaderRule = rules.find((item) => item.loader.includes('ts-loader'));
if (!tsLoaderRule) {
throw new Error(__filename + ': tsLoaderRule not found!');
}
if (tsLoaderRule.options.getCustomTransformers) {
throw new Error(__filename + ': getCustomTransformers already set!');
}
/**
* add the custom transformer
* see: https://docs.nestjs.com/openapi/cli-plugin#using-the-cli-plugin
*/
tsLoaderRule.options = {
...tsLoaderRule.options,
getCustomTransformers: (program) => ({
before: [require('@nestjs/swagger/plugin').before({}, program)],
}),
};
/**
* we must also add a provider plugin
* see: https://github.com/nrwl/nx/issues/2147#issuecomment-587165933
*/
resultConfig.plugins = [
...(resultConfig.plugins || []),
new webpack.ProvidePlugin({
openapi: '@nestjs/swagger',
}),
];
return resultConfig;
};