2016-08-03 107 views
0

我正在使用Angular CLI。它生成以下index.html對我來說:environment.production從哪裏來?

<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>AuthorWizard</title> 
    <base href="/"> 

    {{#unless environment.production}} 
    <script src="/ember-cli-live-reload.js" type="text/javascript"></script> 
    {{/unless}} 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="icon" type="image/x-icon" href="favicon.ico"> 
    <link rel="stylesheet" href="vendor/bootstrap/dist/css/bootstrap.min.css"> 
</head> 
<body> 
    <div class="container"> 
    <app-root>Loading...</app-root> 
    </div> 

    {{#each scripts.polyfills}} 
    <script src="{{.}}"></script> 
    {{/each}} 
    <script> 
     System.import('system-config.js').then(function() { 
     System.import('main'); 
     }).catch(console.error.bind(console)); 
    </script> 



</body> 
</html> 

我很好奇以下三行:

{{#unless environment.production}} 
    <script src="/ember-cli-live-reload.js" type="text/javascript"></script> 
    {{/unless}} 

如果我刪除這些行,現場重裝停止工作。但是,如果我保留行,我運行測試時會出現錯誤。我想將該腳本標籤配置爲只在environment.development時爲真,而不是environment.production爲假時顯示。

environment.production從哪裏來?

回答

0

這是CLI在內部用於解析文檔的Handlebars語法。所以請保持原樣。使用/dist的內置代碼來爲項目提供服務。

在CLI的開發版本中,刪除了handlebars,而代之以使用webpack,在此代碼被刪除的位置。