publicPath: is the path inserted into src="" of img element in html.
<img src="imgs/webpack.svg"/>
So both should have the same path.
pay attention to the tag of <script>
in index.html
,which type is default but not is module
Works
<script src="./build/bundle.js"></script>
Creates Error
<script type="module" src="./build/bundle.js"></script>
I'm distributing a React app with a script tag only on 3rd party sites, so I'm using style-loader
, and not emitting a separate CSS file.
The way I fixed this issue was defining an output.publicPath
in the production webpack configuration and upgrading to the latest webpack version.