-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack-hmr.config.js
80 lines (79 loc) · 2.04 KB
/
webpack-hmr.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const webpack = require('webpack');
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const { RunScriptWebpackPlugin } = require('run-script-webpack-plugin');
module.exports = {
entry: ['./src/main.ts'],
target: 'node',
// externals: [
// nodeExternals(),
// ],
module: {
rules: [
{
test: /.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
mode: 'development',
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
stats: {
colors: true,
modules: true,
reasons: true,
errorDetails: true,
},
plugins: [
// new webpack.HotModuleReplacementPlugin(),
// new RunScriptWebpackPlugin({ name: 'server.js', autoRestart: false }),
new webpack.IgnorePlugin({
/**
* There is a small problem with Nest's idea of lazy require() calls,
* Webpack tries to load these lazy imports that you may not be using,
* so we must explicitly handle the issue.
* Refer to: https://github.com/nestjs/nest/issues/1706
*/
checkResource(resource) {
const lazyImports = [
'@nestjs/core',
'@nestjs/microservices',
'@nestjs/platform-express',
'cache-manager',
'class-validator',
'class-transformer',
// ADD THIS
'@nestjs/microservices/microservices-module',
'@nestjs/websockets',
'socket.io-adapter',
'utf-8-validate',
'bufferutil',
'kerberos',
'@mongodb-js/zstd',
'snappy',
'@aws-sdk/credential-providers',
'mongodb-client-encryption',
'@nestjs/websockets/socket-module',
'bson-ext',
'snappy/package.json'
];
if (!lazyImports.includes(resource)) {
return false;
}
try {
require.resolve(resource);
} catch (err) {
return true;
}
return false;
},
}),
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'server.js',
},
};