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.
I built a react app in single bundle file i.e bundle.min.js by following these steps:
- npx embeddable-create-react-app
- added the following in package.json file's script section:
"web:build": "npm run build && npm run build:bundle",
"build:bundle": "webpack --config webpack.config.js"
- yarn web:build
- It provided me the a bundled file named bundle.min.js at the following path: widget_app/dist/build/static/js/bundle.min.js
I ran the above bundled file on server by using the following command:
- npm install -g http-server
- http-server
My HTML file where I want to display my react widget (bundled file):
<!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).