Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP] compile for browser only #403

Open
wiryonolau opened this issue Sep 6, 2022 · 4 comments
Open

[HELP] compile for browser only #403

wiryonolau opened this issue Sep 6, 2022 · 4 comments
Labels

Comments

@wiryonolau
Copy link

Hi possible to compile for browser only ( es5 or umd ) , for non nodejs project

@couds
Copy link
Owner

couds commented Nov 10, 2022

Can you explain a little what you mean? Like being able to add the scripts directly on your html?

@wiryonolau
Copy link
Author

wiryonolau commented Nov 10, 2022

yeah to be able to be call using <script src="" /> without webpack, like react.js itself we can call in html directly.

@couds
Copy link
Owner

couds commented Nov 16, 2022

Can you provide a code example on how are you using react component with that setup? Thanks

@wiryonolau
Copy link
Author

In react if you use browser only ( non nodejs ) you just import in the header directly

<html>
<head>
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script type="text/javascript" src="/index.js"></script>
</head>
<body>
<div id="root" ></div>
</body>
</html>

index.js

ReactDOM.createRoot(document.getElementById("root")).render(<h1>Hello World</h1>);

Perhaps you can include the final min.js or js in dist folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants