NestJS 优化最小化不适用于 webpack [英] NestJS optimization minimize not work with webpack
问题描述
我正在使用 NestJS.在生产中 minimize
将设置为 true
.当我运行构建
.build后的源码不像开发模式那样工作,所有的路由都没有映射,这个函数映射到其他函数......
I'm using NestJS. In production minimize
will set to true
. When I run build
. The source code after build not work like development mode, all route not map, this function map to other function...
这是我的代码.
module.exports = {
target: 'node',
optimization: {
minimize: true <-- HERE
},
node: {
__dirname: false,
__filename: false,
},
module: {
rules: [
{
test: /.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'server.js',
},
};
有什么帮助吗?
推荐答案
看起来您在 GitHub 问题,但为了任何在搜索中发现此问题的人,问题出在 Webpack 以及在生产模式下使用最小化运行时它如何重命名类.来自卡米尔的报价
Looks like you found your answer on the GitHub issue, but for the sake of anyone finding this problem in a search, the problem is with Webpack and how it renames classes when running in production mode with minimize. Quote from Kamil
Webpack 在生产模式下自动转换类/函数的名称.我建议看看这一章:https://webpack.js.org/configuration/mode/ 并禁用最小化选项.
Webpack automatically transforms the names of classes/functions in the production mode. I'd recommend looking at this chapter: https://webpack.js.org/configuration/mode/ and disabling minimize option.
这篇关于NestJS 优化最小化不适用于 webpack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!