6

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!

2 Answers 2

2

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
      }
    }
Sign up to request clarification or add additional context in comments.

Comments

1

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

2 Comments

..You mean using dev-server as proxy for apache? Like this? nikolay.rocks/2016-01-13-connect-webpack-to-backend
I think you want the way around. Use Apache to proxy /mysite to webpack? In my devtools I saw localhost:8080/__webpack_hmr is from type eventsource so you wouldnt need sockets at all. I'll edit my answer ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.