本文介绍了如何在create-react-app中定义process.env.ENV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 create-react-app 样板的版本 1.0.5 我已经开始接收休闲警告:
*** process.env.ENV未定义,假设'prod'env



我知道如何创建一个自定义的环境变量,但是需要 REACT_APP _ 前缀。



发现由于Chrome的语法扩展名,消息正在显示,并禁用它会删除该消息。



然而,我想知道如何解决这个问题,无论扩展。



我知道StackOverflow还有2个这样的问题,但是它们包括使用Webpack的解决方案。不幸的是,我没有访问Webpack,因为我没有弹出创建反应应用程序,我不打算很快。



有没有办法在 create-react-app process.env.ENV 中声明环境? strong>



编辑:



这是主要的问题。在未弹出的 创建反应应用程序

解决方案

语法扩展是这个不是React的原因。已经使用语法支持记录了请求,这是结果


With the version 1.0.5 of the create-react-app boilerplate I've started receiving the fallowing warning:*** process.env.ENV is not defined, assuming 'prod' env

I know how to create a custom environmental variables, but those require REACT_APP_ prefix.

Now, I've discovered that the message is being shown because of the Chrome's Grammarly extension, and disabling it removes the message.

However, I'd like to know how I can resolve this regardless of the extensions.

I know that there are 2 more questions like this on the StackOverflow, but they include solutions that are using the Webpack. Unfortunately, I have no access to the Webpack, since I haven't ejected the create-react-app, and I don't plan to anytime soon.

Is there a way to declare the environment on process.env.ENV in create-react-app?

EDIT:

This was the main question. Is it technically possible to define it in the non-ejected create-react-app?

解决方案

The Grammarly extension is the cause of this not React. Have logged a request with Grammarly Support and this is the result

这篇关于如何在create-react-app中定义process.env.ENV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 08:36