简体   繁体   English

ReactJS 没有缩小生产中的错误

[英]ReactJS none minified erros in production

Situation: My application is currently under development but I have a separated demosystem which uses the build version of my product for demonstration purpose for potential customers and general interested users.情况:我的应用程序目前正在开发中,但我有一个单独的演示系统,它使用我的产品的构建版本为潜在客户和一般感兴趣的用户演示目的。 My project has a very high ordered Error-Boundary component to catch unhandeled exceptions which allows me to avoid ugly application-crashes.我的项目有一个非常高阶的 Error-Boundary 组件来捕获未处理的异常,这使我能够避免丑陋的应用程序崩溃。 Instead of a normal crash a well formatted error-page will be shown which contains the error message occured combined with the stack-trace.将显示格式良好的错误页面,而不是正常的崩溃,其中包含与堆栈跟踪结合发生的错误消息。

I just realised that in production (after npm run build ) the error and even stack-trace is highly minified and does not allow me to recognize the exact problem-causing piece of code (eg stacktrace is not clearly readable anymore) were the problem occurred and also some customers cannot explain me what they did to get the problem.我刚刚意识到在生产中(在npm run build )错误甚至堆栈跟踪都被高度缩小,并且不允许我识别导致问题的确切代码段(例如,堆栈跟踪不再清晰可读)是否发生了问题并且有些客户无法向我解释他们为解决问题所做的工作。

Is there any way to reproduce the stack-trace original named variables with any kind of translation-table or an option to get full error messages even after the有什么方法可以使用任何类型的转换表或选项来重现堆栈跟踪原始命名变量,即使在

npm build

Edit: Fixed typos and made problem easier to understand.编辑:修正了错别字并使问题更容易理解。

you can eject your ceate-create-app and change optimization inside config/webpack.config.js :您可以弹出您的 ceate-create-app 并在config/webpack.config.js 中更改优化:

    optimization: {
      minimize:  isEnvProduction,
      minimizer: [
        // This is only used in production mode
        new TerserPlugin({
          terserOptions: {

just change minimize to true只需将最小化更改为

or you can generate two builds of application one development and one production.或者您可以生成两个版本的应用程序,一个是开发,一个是生产。

serve development build if user is admin eg如果用户是管理员,则为开发版本提供服务,例如

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM