-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
62 lines (60 loc) · 1.63 KB
/
webpack.config.js
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
51
52
53
54
55
56
57
58
59
60
61
62
const CopyPlugin = require('copy-webpack-plugin');
const swaggerUiModulePath = path.dirname(require.resolve('swagger-ui-dist'));
module.exports = (options, webpack) => {
const lazyImports = [
'@nestjs/microservices/microservices-module',
'@nestjs/websockets/socket-module',
'class-transformer/storage',
];
return {
...options,
externals: [],
output: {
...options.output,
libraryTarget: 'commonjs2',
},
plugins: [
...options.plugins,
new webpack.IgnorePlugin({
checkResource(resource) {
if (lazyImports.includes(resource)) {
try {
require.resolve(resource);
} catch (err) {
return true;
}
}
return false;
},
}),
new CopyPlugin({
patterns: [
{
from: `${swaggerUiModulePath}/swagger-ui.css`,
to: 'src/swagger-ui.css',
},
{
from: `${swaggerUiModulePath}/swagger-ui-bundle.js`,
to: 'src/swagger-ui-bundle.js',
},
{
from: `${swaggerUiModulePath}/swagger-ui-standalone-preset.js`,
to: 'src/swagger-ui-standalone-preset.js',
},
{
from: `${swaggerUiModulePath}/favicon-32x32.png`,
to: 'src/favicon-32x32.png',
},
{
from: `${swaggerUiModulePath}/favicon-16x16.png`,
to: 'src/favicon-16x16.png',
},
{
from: `${swaggerUiModulePath}/oauth2-redirect.html`,
to: 'src/oauth2-redirect.html',
},
],
}),
],
};
};