mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #12096 from grafana/davkal/11446-fix-systemjs-cachebust
Fix cache busting for systemjs imports for plugins
This commit is contained in:
commit
40844614bf
@ -27,6 +27,13 @@ import 'rxjs/add/observable/from';
|
||||
import 'rxjs/add/operator/map';
|
||||
import 'rxjs/add/operator/combineAll';
|
||||
|
||||
// add cache busting
|
||||
const bust = `?_cache=${Date.now()}`;
|
||||
function locate(load) {
|
||||
return load.address + bust;
|
||||
}
|
||||
System.registry.set('plugin-loader', System.newModule({ locate: locate }));
|
||||
|
||||
System.config({
|
||||
baseURL: 'public',
|
||||
defaultExtension: 'js',
|
||||
@ -40,23 +47,14 @@ System.config({
|
||||
css: 'vendor/plugin-css/css.js',
|
||||
},
|
||||
meta: {
|
||||
'*': {
|
||||
'plugin*': {
|
||||
esModule: true,
|
||||
authorization: true,
|
||||
loader: 'plugin-loader',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// add cache busting
|
||||
var systemLocate = System.locate;
|
||||
System.cacheBust = '?bust=' + Date.now();
|
||||
System.locate = function(load) {
|
||||
var System = this;
|
||||
return Promise.resolve(systemLocate.call(this, load)).then(function(address) {
|
||||
return address + System.cacheBust;
|
||||
});
|
||||
};
|
||||
|
||||
function exposeToPlugin(name: string, component: any) {
|
||||
System.registerDynamic(name, [], true, function(require, exports, module) {
|
||||
module.exports = component;
|
||||
|
3
public/vendor/plugin-css/css.js
vendored
3
public/vendor/plugin-css/css.js
vendored
@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
var bust = '?_cache=' + Date.now();
|
||||
var waitSeconds = 100;
|
||||
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
@ -47,7 +48,7 @@ if (typeof window !== 'undefined') {
|
||||
var link = document.createElement('link');
|
||||
link.type = 'text/css';
|
||||
link.rel = 'stylesheet';
|
||||
link.href = url;
|
||||
link.href = url + bust;
|
||||
if (!isWebkit) {
|
||||
link.onload = function () {
|
||||
_callback();
|
||||
|
Loading…
Reference in New Issue
Block a user