How can I import a custom JS file?

Hello guys,

How can I import a personal custom JS script in my project ? It’s a script which creates particules on a canvas. I am a beginner on Ionic and Angular.

I found a way, but it doesn’t seem like it should be done that way.

What I did is that I created a copy-config.js file in a config folder with those lines :

copyVanilla: {
        src: [
        // Very important, the dest folder to reference from index.html
        dest: '{{WWW}}/assets/js/vanilla.js'

And I just added on my index.html file 2 lines :

<canvas id="space"></canvas>
<script src="assets/js/vanilla.js"></script>

It does work but I really don’t know if it is the correct way to do it… :confused:

Is there a way to do it like that ?

import { MyScript } from "./assets/js/vanilla"

And then call the functions in the file :


Many thanks to those who will take the time to explain me.

I am trying to do the same thing. Did you find how?