Deploy-url字体Angular-cli

时间:2017-07-14 14:17:10

标签: angular angular-cli

我正在使用ancgular-cli构建我的应用程序,我在生产中有这样的命令 -

ng build --aot --target=production -e ${NG_ENV:-prod} --deploy-url ${NG_DEPLOY_URL:-https://app.contentsnare.com/} --output-path dist && find dist \\( -name '*.css' -o -name '*.js' \\) -exec gzip --keep --quiet --force {} \\;

,一切正常,但glyphicons字体的连接存在问题。 他们得错了路径,错误看起来像这样 - http://joxi.ru/a2XYkX6syDb01A,不明白为什么以及如何解决它。

我认为这是因为deploy-url,但不知道如何修复它。

1 个答案:

答案 0 :(得分:2)

如果使用static.json进行部署,或者使用nginx,那么你应该把它放到配置中:

"headers": {
   "*/glyphicons-halflings-regular.*": {
     "Access-Control-Allow-Origin": "*"
   }
 } 

例如,我在Heroku上使用这个buildpack,我应该在static.json中为它编写以下内容:

{
 "root": "dist/",
 "https_only": true,
 "routes": {
   "/**": "index.html"
  },
  "headers": {
    "*/glyphicons-halflings-regular.*": {
      "Access-Control-Allow-Origin": "*"
    }
   }
}
相关问题