I'm a little bit confused about using Vue and node simultaneously. You can run a Vue-cli application locally by typing npm run dev
and it runs on one port, and then I also created an express server file with some routes and that runs on another port. Everything works fine...
But why does Vue-cli have to "run" as if its a server, when it's just client-side code? Does this mean in production I really have to be occupying two ports at the same time for one app?
No, you will npm build
your front end and have your express server server it statically. Vue-cli is helpful because it sets up the webpack scaffolding and enables hot reloading.
When you use 'npm run dev' you start the webpack server which builds your vue code into javascript code 'dynamically' so you can work on it with hot reload and you will have a 'http://localhost' behaviour instead of a 'file://' etc.
In production build, 'npm run build' you will get a javascript file and an html file to put on your server. You may need some htaccess configs to view your site if you are using vue-router but nothing more than that, you will use those files like a static webpage. For instance, i think it's safe to say that an apache server handles the job that webpack does in development.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With