1
I am creating a simple application and need to import some specific js and css files on a given page but how do you do that? In my template (Login.Vue) I tried
<script>
require('./assets/js/pages/forms.js');
</script>
and
<script src="./assets/js/pages/forms.js"></script>
remembering that I am using Laravel to generate the application, so all the files are concentrated in Resources/Assets/, already the style files and other js files are in /public/Assets/.
How could I, in my vuejs template, import some file that is in the public folder?
Yes, I am using everything in one place. I can’t imagine how I would run the two independent but exchanging information. I tried to do the way you suggested but there were no changes in the css and js of the page.
– Felipe Paz
Too bad, if you wish, I can remove the answer. I don’t know how your project is currently, but usually I prefer the separation in case of SPA application, without the use of the Laravel Slide. Basically it is two separate projects, and the communication (most of it) is through the Laravel routes available in the Routes folder in the api.php file, where the request is made from Vuejs with Vue-Resource or Axios for this back-end route. Settings should also be done on your . env if I’m not mistaken located at the root of the project, as well as some Docker settings if using.
– guastallaigor
No, you can leave the answer. It already gives me a north to review my learning and try some tutorial that teaches to do this way. I believe that the project gets more organized by leaving backend in one location and frontend in another. By the way, when deploying the project on some host, such as Hostinger, hostgator and others, it would be the same thing to do for an application with only Windows?
– Felipe Paz