mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-20 19:02:33 +00:00
Remove internal scripts if minify is true and the CDN provider is not local (#251)
This commit is contained in:
parent
e30159875a
commit
959e100298
@ -2,10 +2,24 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const internalScripts = [];
|
||||||
|
|
||||||
|
hexo.theme.addProcessor('js/*', file => {
|
||||||
|
internalScripts.push(file.params[0]);
|
||||||
|
});
|
||||||
|
|
||||||
hexo.extend.filter.register('after_generate', () => {
|
hexo.extend.filter.register('after_generate', () => {
|
||||||
const theme = hexo.theme.config;
|
const theme = hexo.theme.config;
|
||||||
if (!theme.minify) return;
|
if (!theme.minify) return;
|
||||||
|
|
||||||
|
if (theme.vendors.internal !== 'local') {
|
||||||
|
// Remove all internal scripts
|
||||||
|
internalScripts.forEach(path => {
|
||||||
|
hexo.route.remove(path);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!hexo.locals.get('pages').some(page => page.type === 'schedule')) {
|
if (!hexo.locals.get('pages').some(page => page.type === 'schedule')) {
|
||||||
hexo.route.remove('js/schedule.js');
|
hexo.route.remove('js/schedule.js');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user