使用 EmberJS 将版本添加到应用程序文件
Add version to app files with EmberJS
我有下一个index.html:
<!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 文件中不起作用。
那么如何将版本添加到我的应用程序文件中?
您提到 我想将版本添加到我的 css 和 js 文件中,以防止用户在版本增长时从缓存中加载这些文件。
默认情况下,Ember CLI 将 md5 散列放在资产 url 的末尾。这样浏览器就可以跟踪更改。这称为指纹识别。这在生产版本中默认启用。
要期待指纹识别,请查看 this doc。
此外,如果您想使用您的版本作为指纹,而不是使用 md5 哈希;您可以自定义 fingerprint
选项。使用 require('git-repo-version')
获取值并将值设置为 fingerprint
的 customHash
。
但是,默认配置就足够了。
我有下一个index.html:
<!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 文件中不起作用。
那么如何将版本添加到我的应用程序文件中?
您提到 我想将版本添加到我的 css 和 js 文件中,以防止用户在版本增长时从缓存中加载这些文件。
默认情况下,Ember CLI 将 md5 散列放在资产 url 的末尾。这样浏览器就可以跟踪更改。这称为指纹识别。这在生产版本中默认启用。
要期待指纹识别,请查看 this doc。
此外,如果您想使用您的版本作为指纹,而不是使用 md5 哈希;您可以自定义 fingerprint
选项。使用 require('git-repo-version')
获取值并将值设置为 fingerprint
的 customHash
。
但是,默认配置就足够了。