I have a svelte project that uses Vite for its build tooling. I want to import a js file from the sakura-js package and call it in my index.html file. It works locally when I use the script tag like this:
<script src="/node_modules/sakura-js/dist/sakura.min.js"></script>
But in prod, it gives a 404 error trying the script. How do I import the script so it works in prod?
2
Answers
You need to use a JavaScript file from the sakura-js package in production.
In your main script file (e.g., main.js or App.svelte), you can import the library like so:
import ‘sakura-js/dist/sakura.min.js’;