A
A
Alexey2021-09-29 11:14:38
JavaScript
Alexey, 2021-09-29 11:14:38

How to fix browser MIME error for import jpg in js?

error with MIME types
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "image/jpeg". Strict MIME type checking is enforced for module scripts per HTML spec.

due to import GrassTexture from '../../static/textures/grass_background.jpg';

webpack creates the build as I need and seems to work well)

devServer: {
    publicPath: '/public/',
    compress: true,
    port: 9000,
    hot: true,
    open: true,
  }


But in webpack's devServer mode or in a third-party liveServer in the browser, this error occurs. I could not find something, how to bypass the browser restriction, what should I do?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question