Reputation: 725
So my backend is PHP based (processwire), served by trusty old MAMP (localhost:8888/mysite
). I'd like to serve my vue.js app from the same server, as well.
npm run dev
starts a local server on localhost:8080
, that works for doing the front end stuff, hot reloading and all.
With npm run build
i can build my app so it can be served from MAMP.
But how can I get hot reloading working over MAMP so I can keep developing through apache (using localhost:8888/mysite
)? Is this possible?
thank you!
Upvotes: 6
Views: 2647
Reputation: 725
I tried but couldn't get hot loading to work by proxying through Apache. The other way around wasn't so hard, in webpack.config.js:
proxy: {
'/mysite/api/**': {
target: 'http://localhost:8888',
secure: false,
"changeOrigin": true
}
}
Upvotes: 2
Reputation: 474
You need the dev-server from webpack to get it running.
But you could use apache as proxy for it. Probably this could work (assume Apache an webpack-dev-server runs on localhost:8080
ProxyPass /mysite http://localhost:8080/mysite
ProxyPassReverse /mysite http://localhost:8080/mysite
So the tricky Part is to tell Webpack to server under /mysite
. That depends an your config. If you come from the Vue webpack template (generate with vue-cli) you have assetsPublicPath
in your /config/index.js
Upvotes: 1