Is there a way to achieve this? I use react.js in the front end only and want to keep it like this.
-
Can you detail more your question? What's a normal JavaScript source? Are you using ES6 ? SCSS or any preprocessing tool ? – dbrrt Sep 24 '17 at 21:00
-
ES6, Babel. With normal js source I mean – Lokomotywa Sep 24 '17 at 21:03
-
I'd pack it, move it to a CDN, if no one did that before, and push it into my HTML file in src props of one – dbrrt Sep 24 '17 at 21:08
-
ok, I am pretty new to this stuff so I dont get it. After installing react toolbox with npm I get a huge directory `node_modules`, so how do I pack this and move it to a CDN? – Lokomotywa Sep 24 '17 at 21:13
-
1If you want to gain time with that and React-toolbox is not a constraint, I'd recommend you to give a try to https://www.muicss.com/ – dbrrt Sep 24 '17 at 21:17
2 Answers
When you build your application via Yarn/npm, that's what basically you'd be doing. The system will bundle your assets and generates an HTML file. If you open the built index.html you should see your parsed React app in plain JS and HTML.
If you plan to put the build on a CDN, all you need to do is move the assets (JS and CSS) and the index.html wherever you want to host them. Ensure that <script>
and <link>
are pointing to the bundled assets within your index.html.
<script type="text/javascript" src="/static/js/your-bundle-main.js"></script>
<link href="/static/css/your-bundlemain.0a265734.css" rel="stylesheet">

- 3,792
- 2
- 21
- 32
You can use unpkg, is a fast, global content delivery network for everything on npm. Use it to quickly and easily load any file from any package using a URL like:
<script src="unpkg.com/react@15.3.1/dist/react.min.js"></script>
<script src="unpkg.com/react-dom@15.3.1/dist/react-dom.min.js"></script>

- 1,435
- 2
- 11
- 17