how to include external libraries in Ionic

2

Normally when you are making a web the libraries are included as follows:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/aos/2.2.0/aos.css"

<script src="https://cdnjs.cloudflare.com/ajax/libs/aos/2.2.0/aos.js"></script>

But in Ionic the structure of the document is different, someone knows how I can include these libraries in an Ionic project

    
asked by Talked 04.04.2018 в 18:10
source

3 answers

1

If the library / module exists in npm ( as it seems to be the case for years ), you would only have to Go to the directory of your project and execute the following command (as indicated in the instructions ):

npm install aos --save

That should download the necessary files and add the dependencies in the configuration files.

If it is a library that you have downloaded, then the general idea is that you have to put the downloaded libraries in the structure of your project and then import those local copies instead of copies to online libraries.

The steps to follow would be something like this:

  • Create your project with ionic
  • Browse to the src/assets directory of your project
  • Create a directory for the JS and CSS (for example the directories js and css )
  • Open to edit your index.html (it should be directly in the src directory)
  • Add reference to JS: <script src="assets/js/tu.js></script>
  • Add the reference to the CSS: <link rel="stylesheet" href="assets/css/tu.css" />
  • answered by 04.04.2018 / 19:40
    source
    1

    Depending on if you use npm, use this command

    • npm install aos --save

    If you are using yarn

    • yarn add aos

    It will install it and add it to your package.json

    I leave this reference link Install

        
    answered by 04.04.2018 в 19:34
    1

    Well, what you can do is enter the links in your "index.html" file

    <script src="https://cdnjs.cloudflare.com/ajax/libs/aos/2.2.0/aos.js"></script>
    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/aos/2.2.0/aos.css">
    

    This file can be found in the root of your project, for example I have it in this location

    I hope I can help you.

        
    answered by 04.04.2018 в 20:10