2017-10-10 15 views
1

文件,我旁边的index.html:版本添加到App与EmberJS

<!DOCTYPE html> 
<html> 

<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> {{content-for 'head'}} 
    <meta name="fragment" content="!"> 

    <link rel="icon" href="/assets/favicon.ico"> 
    <link rel="stylesheet" href="{{rootURL}}assets/vendor.css?{{app-version hideSha=true}}"> 
    <link rel="stylesheet" href="{{rootURL}}assets/ember-drink-it.css?{{app-version hideSha=true}}"> {{content-for 'head-footer'}} 
</head> 

<body> 
    {{content-for 'body'}} 

    <script src="{{rootURL}}assets/vendor.js?{{app-version hideSha=true}}"></script> 
    <script src="{{rootURL}}assets/ember-drink-it.js?{{app-version hideSha=true}}"></script> 

    {{content-for 'body-footer'}} 
</body> 

</html> 

我想版本添加到我的CSS和JS文件,以防止版本时,用户的增长从缓存中加载这些文件。正如你看到的,我已经尝试使用ember-cli-app-version插件,但由于某些原因,它的助手在index.html文件中不起作用。

那么如何将版本添加到我的应用程序文件?

回答

1

您提到过我想将版本添加到我的css和js文件,以防止用户在版本增长时从缓存中加载这些文件。

默认情况下,Ember CLI在资产的url的末尾放置一个md5散列。这样浏览器就可以跟踪这些变化。这被称为指纹识别。这在默认生产版本中启用。

期待有关指纹识别看看this doc

此外,而不是使用MD5散列,如果你想使用你的版本作为指纹;您可以自定义fingerprint选项。通过使用require('git-repo-version')获取价值并将其值设置为fingerprintcustomHash

但是,默认配置是足够好的。

+0

由于某些原因,_fingerprint_在我的构建文件中被禁用。我会尽快测试它。 – Crabar

+0

它的工作原理。谢谢。 – Crabar