I have tried to solve this using path, publicpath, contentBased but no luck. (only working if bundle.js and index.html are in same folder)
Env: Webpack 5 + webpack-dev-server + react.
Issue: unable to load application properly in wp dev server, either it show contents folders or not hot reload.
This working fine if generate html & bundle in same folder, but for some reason, I have to keep them in different folders.
Folder structure
dist\bundle.js
dist\style.css
public\index.html (generated by HTML-webpack-plugin)
public\.... (other files)
webpack config
output: {
path: path.resolve(..., 'dist') //also tried to generate dist inside public
filename: bundle.js
//publicPath: path.resolve(..., 'dist') //etc
}
devServer: {
contentBase: path.resolve(..., 'public')
}
I have tried multiple combination with no luck, I want to keep single version of html file and avoid modify src manually for dev builds.
Could someone please guide with right configuration.