[英]bundle.min.js not displaying components in html file
I want to display my react components in simple scrtipt tag (a widget) I created simple react app with npx create-react-app widget_app.
我想在简单的脚本标签(一个小部件)中显示我的反应组件我用 npx create-react-app widget_app 创建了简单的反应应用程序。 I built a react app in single bundle file ie bundle.min.js by following these steps:
我按照以下步骤在单个包文件中构建了一个反应应用程序,即 bundle.min.js:
"web:build": "npm run build && npm run build:bundle",
"web:build": "npm run build && npm run build:bundle",
"build:bundle": "webpack --config webpack.config.js"
“构建:捆绑”:“webpack --config webpack.config.js”
I ran the above bundled file on server by using the following command:我使用以下命令在服务器上运行了上述捆绑文件:
My HTML file where I want to display my react widget (bundled file):我想在其中显示我的反应小部件(捆绑文件)的 HTML 文件:
<:doctype html> <html lang="en"> <head> <title>Embedded Widget App</title> </head> <body> <script type="text/javascript" src="http.//127.0.0:1.8080/bundle.min.js"></script> </body> </html>
But this html file not displaying any thing (as in screenshot attached).但是这个 html 文件没有显示任何东西(如随附的屏幕截图所示)。
This is because source map files are disabled by default, so when to create a build of your project source map file are not generated.这是因为默认情况下禁用源 map 文件,因此在创建项目的构建时不会生成源 map 文件。 To enable add the following line in a.env file at the root of your project.
要启用在项目根目录的 a.env 文件中添加以下行。
GENERATE_SOURCEMAP = true
You can refer this article for more information: Easy Debugging In React With WebPack Source Maps您可以参考这篇文章以获取更多信息: 使用 WebPack 源映射在 React 中轻松调试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.