Why webpack needs a output publicpath when using hot module replacement?

195 views Asked by At

I dont understand why webpack needs a output.publicPath property when working with HMR, I set the devServer to serve files from same directory of output.path, if I don't put output.publicPath, then it shows me this error: webpack error

Please explain to me what exactly output.publicPath does.

Thanks in advance and I'm sorry for my english.

1

There are 1 answers

0
Diego Perdomo On

I got it!, the ouput.path property is a place in the server where webpack will put the bundle file, but the publicPath is the place where the browser will ask for files when needed (in this case, the json manifiest and updated chunks for HMR), if you dont put that, then the browser wont know where to ask for that and the devServer will return a 404 not found.

I hope this to be useful for someone else with the same problem.