如何在create react应用程序中生成源地图? [英] How to generate sourcemaps in create react app?
问题描述
我想知道如何在create-react-app中生成源地图?他们隐含地完成了吗?它们存放在构建文件夹中吗?
I'm wondering how to generate source maps in create-react-app? are they done implicitly? and do they live in the build folder
我已经阅读了很多关于使用webpack生成它们的信息,但是我的应用程序没有使用它,所以我想知道如何
I've read quite a lot about them being generated with webpack but my app is not using it, so I was wondering how I do this without webpack?
我也不想弹出
推荐答案
根据CRA文档,默认情况下会在生产模式下生成源地图。
According to CRA documentation, source maps are generated by default in production mode.
但是,您可以通过运行以下方式禁用此行为(在生产模式下生成源地图): GENERATE_SOURCEMAP = false ./node_modules/.bin/react-scripts build
或如果您希望这种行为永久存在,请执行以下解决方案之一:
However, you can disable this behavior (generating source maps in production mode) by running GENERATE_SOURCEMAP=false ./node_modules/.bin/react-scripts build
or if you want this behavior to be permanent, do one of the following solutions:
- 在.env文件中设置GENERATE_SOURCEMAP = false。
- 修改package.json中的脚本并替换
构建:反应脚本构建
与构建: GENERATE_SOURCEMAP = false反应脚本构建
- Set GENERATE_SOURCEMAP=false in your .env file.
- Modify the scripts in your package.json and replace
"build": "react-scripts build"
with"build": "GENERATE_SOURCEMAP=false react-scripts build"
https://facebook.github.io/create-react-app/docs/advanced-configuration
这篇关于如何在create react应用程序中生成源地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!