Webpack5 Automatic publicPath is not supported in this browser
Solution 1:
The suggested solutions didn't work for me. However, I found that setting publicPath
to an empty string did the trick.
output: {
publicPath: '',
...
}
Solution 2:
I encountered the same issue. My code compiles into the dist-folder without any further structure. The following code works for me and is simple since I need an empty path.
'module': {
rules: [
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: ''
}
},
{
loader: "css-loader"
}
]
}
]
}
You can go crazy and do things like that, too:
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: (resourcePath, context) => {
return path.relative(path.dirname(resourcePath), context) + '/';
},
},
},
Details you can find here: https://webpack.js.org/plugins/mini-css-extract-plugin/#the-publicpath-option-as-function