Closed Darkzarich closed 3 years ago
Technically, a workaround would be removing hashes from bundle names in development (and it will also increase building speed) but I would really like to know what is going wrong here
HMR and [contenthash]
in mini-css-extract-plugin
is not supported
Duplicate https://github.com/webpack-contrib/mini-css-extract-plugin/issues/444, nothing to fix here, I will fix it after webpack-dev-server stable release
If anyone is facing the same issue using [contenthash]
or any other hash in bundle name just remove this for development and leave for production like so
const isProd = process.env.NODE_ENV === 'production'
const isDev = !isProd
const filename = (ext) =>
isDev ? `bundle.${ext}` : `bundle.[fullhash].${ext}`
...
output: {
filename: filename('js'),
path: path.resolve(__dirname, 'dist'),
clean: true,
}
Code
package.json, dependencies
Expected Behavior
webpack-devserver
updates the page on changesActual Behavior
webpack-dev-server
sometimes (usually after some amount of similar changes back and forth or a error in terminal) doesn't updatebundle.css
on changes in a*.scss
file. There is an error in devtools terminal:Refused to apply style from 'http://localhost:8080/bundle.827759789137d0c65a1e.css?1617926518186' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
Updating the page with F5 helps to load an actual version.
Apparently, a new style file was compiled on a change but html was not updated and
webpack-dev-server
tried to access not existing anymore style file.UPD
It also stops detecting changes in any other files... Or, to be more accurate, it does say in the devtools that an update is detected but nothing happens, the content of the page is not updated