且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

拒绝执行脚本 from 因为其 MIME 类型 ('text/html') 不可执行,并且启用了严格的 MIME 类型检查

更新时间:2021-10-14 21:30:48

您的 webpack 配置格式不正确.所以你的 devServer 返回的是后备 html 文件而不是包.

Your webpack config is malformed. So your devServer is returning the fallback html file instead of the bundle.

因此为什么脚本使用 ('text/html') MIME 类型.

Hence why the script is served with the ('text/html') MIME type.

devServer: {
    historyApiFallback:{
      index:'/dist/index.html'
    },
  }

你的意思可能是这样的:

You probably meant something like this:

devServer: {
  historyApiFallback: true
}

https://webpack.js.org/configuration/dev-server/