mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-30 22:34:10 -05:00
feat(web): add a config item to web,let the developer can select whether enable the html cache (#3108)
* 为web添加cache配置项,用户可以自己决定是否启用Html缓存 * related to the change for https://github.com/verdaccio/verdaccio/pull/3108 * related to the change for https://github.com/verdaccio/verdaccio/pull/3108 * apply changes from 5.x branch Co-authored-by: fengdi <fengdi@bbktel.com> Co-authored-by: Juan Picado <juanpicado19@gmail.com>
This commit is contained in:
parent
d65db96ff0
commit
d08fe29d97
5 changed files with 32 additions and 4 deletions
6
.changeset/slow-carrots-relate.md
Normal file
6
.changeset/slow-carrots-relate.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
'@verdaccio/config': minor
|
||||||
|
'@verdaccio/web': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
feat(web): add a config item to web,let the developer can select whet……her enable the html cache
|
|
@ -19,6 +19,7 @@ web:
|
||||||
# sort_packages: asc
|
# sort_packages: asc
|
||||||
# convert your UI to the dark side
|
# convert your UI to the dark side
|
||||||
# darkMode: true
|
# darkMode: true
|
||||||
|
# html_cache: true
|
||||||
# HTML tags injected after manifest <scripts/>
|
# HTML tags injected after manifest <scripts/>
|
||||||
# scriptsBodyAfter:
|
# scriptsBodyAfter:
|
||||||
# - '<script type="text/javascript" src="https://my.company.com/customJS.min.js"></script>'
|
# - '<script type="text/javascript" src="https://my.company.com/customJS.min.js"></script>'
|
||||||
|
|
|
@ -23,7 +23,22 @@ web:
|
||||||
# gravatar: false
|
# gravatar: false
|
||||||
# by default packages are ordercer ascendant (asc|desc)
|
# by default packages are ordercer ascendant (asc|desc)
|
||||||
# sort_packages: asc
|
# sort_packages: asc
|
||||||
|
# convert your UI to the dark side
|
||||||
# darkMode: true
|
# darkMode: true
|
||||||
|
# html_cache: true
|
||||||
|
# HTML tags injected after manifest <scripts/>
|
||||||
|
# scriptsBodyAfter:
|
||||||
|
# - '<script type="text/javascript" src="https://my.company.com/customJS.min.js"></script>'
|
||||||
|
# HTML tags injected before ends </head>
|
||||||
|
# metaScripts:
|
||||||
|
# - '<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>'
|
||||||
|
# - '<script type="text/javascript" src="https://browser.sentry-cdn.com/5.15.5/bundle.min.js"></script>'
|
||||||
|
# - '<meta name="robots" content="noindex" />'
|
||||||
|
# HTML tags injected first child at <body/>
|
||||||
|
# bodyBefore:
|
||||||
|
# - '<div id="myId">html before webpack scripts</div>'
|
||||||
|
# Public path for template manifest scripts (only manifest)
|
||||||
|
# publicPath: http://somedomain.org/
|
||||||
|
|
||||||
# translate your registry, api i18n not available yet
|
# translate your registry, api i18n not available yet
|
||||||
# i18n:
|
# i18n:
|
||||||
|
|
|
@ -26,6 +26,9 @@ export default function renderHTML(config, manifest, manifestFiles, req, res) {
|
||||||
const base = getPublicUrl(config?.url_prefix, req);
|
const base = getPublicUrl(config?.url_prefix, req);
|
||||||
const basename = new URL(base).pathname;
|
const basename = new URL(base).pathname;
|
||||||
const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;
|
const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;
|
||||||
|
const needHtmlCache = [undefined, null].includes(config?.web?.html_cache)
|
||||||
|
? true
|
||||||
|
: config.web.html_cache;
|
||||||
const darkMode = config?.web?.darkMode ?? false;
|
const darkMode = config?.web?.darkMode ?? false;
|
||||||
const title = config?.web?.title ?? WEB_TITLE;
|
const title = config?.web?.title ?? WEB_TITLE;
|
||||||
const login = hasLogin(config);
|
const login = hasLogin(config);
|
||||||
|
@ -81,8 +84,10 @@ export default function renderHTML(config, manifest, manifestFiles, req, res) {
|
||||||
manifest
|
manifest
|
||||||
);
|
);
|
||||||
debug('template :: %o', webPage);
|
debug('template :: %o', webPage);
|
||||||
cache.set('template', webPage);
|
if (needHtmlCache) {
|
||||||
debug('set template cache');
|
cache.set('template', webPage);
|
||||||
|
debug('set template cache');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
debug('reuse template cache');
|
debug('reuse template cache');
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,8 @@ web:
|
||||||
- '<script type="text/javascript" src="https://browser.sentry-cdn.com/5.15.5/bundle.min.js"></script>'
|
- '<script type="text/javascript" src="https://browser.sentry-cdn.com/5.15.5/bundle.min.js"></script>'
|
||||||
- '<meta name="robots" content="noindex" />'
|
- '<meta name="robots" content="noindex" />'
|
||||||
scriptsbodyBefore:
|
scriptsbodyBefore:
|
||||||
- '<div id="myId">html before webpack scripts</div>'
|
- '<div id="myId">html before webpack scripts</div>'
|
||||||
|
html_cache: true
|
||||||
```
|
```
|
||||||
|
|
||||||
All access restrictions defined to [protect your packages](protect-your-dependencies.md) will also apply to the Web Interface.
|
All access restrictions defined to [protect your packages](protect-your-dependencies.md) will also apply to the Web Interface.
|
||||||
|
@ -73,7 +74,7 @@ i18n:
|
||||||
| scriptsBodyAfter | string[] | No | any list of strings | `>=5.0.0` | inject scripts after the <body/> tag |
|
| scriptsBodyAfter | string[] | No | any list of strings | `>=5.0.0` | inject scripts after the <body/> tag |
|
||||||
| metaScripts | string[] | No | any list of strings | `>=5.0.0` | inject scripts inside <head/> |
|
| metaScripts | string[] | No | any list of strings | `>=5.0.0` | inject scripts inside <head/> |
|
||||||
| scriptsbodyBefore | string[] | No | any list of strings | `>=5.0.0` | inject scripts before the <body/>|
|
| scriptsbodyBefore | string[] | No | any list of strings | `>=5.0.0` | inject scripts before the <body/>|
|
||||||
|
| html_cache | boolean | No | true | `>=v5.9.0` | whether the html cache is enabled, default true |
|
||||||
|
|
||||||
> The recommended logo size is `40x40` pixels.
|
> The recommended logo size is `40x40` pixels.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue