How to include the CSS and JS in a static website without using CDN url’s?
When we tried to download the JS file to local and refer it <script type='text/javascript' src="ionic.js"></script> the page loads “Empty” with an error in Chrome dev console. The same works when referred from CDN.
I am just trying to give you a way to make this work. No idea what the best way to achieve this is.
You can probably copy the @ionic/core folder from node_modules then to whatever location you want and include it from there. npm is just a nice way to get the whole package downloaded and installed to a known location.
@surenkonathala It works from the CDN because not only that js file is in the CDN, but the dependent files (and the subdependencies too) are in the CDN.
You could try to download all the files from the CDN to be sure:
(this is the dist directory, so probably all static files are here).
Or you could see in the Network tab of the Developer Tools all files that are downloaded (when you use the CDN), then you go and download them manually (when you click in the file in the Network tab, it should show the complete path in the Request URL field).
After including the entire @ionic/core folder in my static website folder, the pages with ion components load properly. So lesson learnt is that “ionic.js” depends on about another 135 js files under @ionic/core/dist/ionc .
Very nice! But, why dont use direct inside the node_modules cause npm handles it ? And how do you get code completion, I am using Visual Studio Code and when I install all packages I get code completion but this time not
from the index.html of my app, which should run on a local network with no access to internet .
I tried putting
import "@ionic/core";
at the begining of my app.ts and everything is functionally fine, with no access to dependencies on internet, but the appearance of some of my components is mangled, while it is ok when using the cdn.
do the npm i @ionic/core in a folder and then copy the full content of node_modules/@ionic/core/dist into a local folder and then refer to this using the script tags.
Uncaught TypeError: Failed to resolve module specifier “tslib”
in the browser, and the components are still mangled. Will include this library too…
BTW I use Stencil.js on top of ionic, so I thought it would be automagically linked …
I think you may want to create a new topic and outline your situation. If you are using stencil, then you are not into a static website situation which this topic is mostly about and also got me triggered to answer the way I did
If you are in a stencil project and working with CDN to have Ionic included, you are either doing something very special or something out of the ordinary. Without me being expert on Stencil btw.
Next, a new topic with a new tag will get the proper expertise in the community eyeballing the issue