最近我遇到了一个问题,我们在构建管道 yaml 脚本中使用了“npm run build”命令。然后是'base-href','configuration'等参数。构建通过并且部署成功但是当我们测试应用程序时,它不会呈现页面,但控制台会出现以下或类似的错误。
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
runtime-es2015.js:1
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
polyfills-es2015.js:1
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
vendor-es2015.js:1
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
main-es2015.js:1
我们在 yaml 中使用的命令是
npm run build -- "-c=<environment> --base-href='/Domain-href-url/'"
SO中建议的类似问题没有解决或帮助,因为脚本本身在本地工作,使用package.json cmds工作正常,在Azure管道中使用vNext构建管道进行角度工作(如果没有传递参数)。但是我们需要环境参数和base-href。