How to create Node.js Express app serving a Vue.js SPA?
These will be different for your dev and prod environments...
For development look into concurrently - it basically allows you to create a single script in your package.json to start both the client and server concurrently and will watch for changes etc...
For production, you would need something like this in your app.js:
if (process.env.NODE_ENV === 'production') { app.use(express.static('client/build')); const path = require('path'); app.get('*', (req, res) => { res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html')); });}
(The code above assumes that your directory structure has a client folder with a build folder after having run npm run build
I'm more familiar with React than Vue... but the logic should be the same...)