I'm trying to include some scripts to my vue app. but all that i've tried so far didn't work.
I'm using Vue 2 and created my project with the vue CLI.
when i try just adding the script tags to my index.html
<script src="../src/assets/js/typewriter-effect.min.js"></script>
<script src="../src/assets/js/custom.js"></script>
I get this error:
Uncaught SyntaxError: Unexpected token '<'
Which i later understood from a post:
So if you are running the local dev server for instance, the browser tries to load the file being served at http://localhost:8080/~some-npm-package/path/to/lib.js.
The dev server is setup to just serve whatever is in the index.html regardless of the actual URL, so it serves the index.html when you try and fetch http://localhost:8080/~some-npm-package/path/to/lib.js.
The browser tries to read this file as a script but the first line of the index.html file is - hence the SyntaxError: expected expression, got '<' that you see.
So my workaround was to use CDN, but even though I could see form devTools that the script was loaded, it didnt work on the page, there was no change. Besides, some of my scripts are only available locally and not from CDNs.
I tried importing in main.js
import './assets/js/slick.min.js'
import './assets/js/custom.js'
or from App.vue
But that didnt seem to work.