Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
Newbie Getting Started Question
-
I’m new to both Cordova and OnSen so forgive my ignorance.
Two add OnSen to a Cordova project the getting started quide cites two approaches:
-
You can add the css/js files via a CDN. I can do this and it works, assuming I remove the default Content-Security-Policy but I’d rather not do this.
-
The second approach cited is to install using node. I’ve done this and I can see the folder in my node_modules folder but the guide just stops there and doesn’t give any suggestions on how to include in your project.
I do have an Angular background and for an Angular project I would just import the resources but what about a simple HTML/CSS application?
-
Is there a better way to add them to my project other that to just copy/paste into my local js/css folders?
-
Being new to Cordova as well, is it a bad idea to just relatively reference the node_modules folder? Ie will they get built properly?
-
-
The simplest way is either:
- Use a CDN.
- Download the files from the CDN manually and put them in your source director.
Or if you want to use npm you will need to use a bundler such as rollup.
This is an example to show how to use OnsenUI with a local copy:
https://github.com/monaca-templates/onsenui-v2-js-minimum
-
Thanks, I wasn’t sure if there was an easier way but this makes sense.
I can play with a bundler for a more elegant solution later but per the example I just made a /lib folder and dropped everything in there.