mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-18 18:33:42 +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';
|
||||
|
||||
const internalScripts = [];
|
||||
|
||||
hexo.theme.addProcessor('js/*', file => {
|
||||
internalScripts.push(file.params[0]);
|
||||
});
|
||||
|
||||
hexo.extend.filter.register('after_generate', () => {
|
||||
const theme = hexo.theme.config;
|
||||
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')) {
|
||||
hexo.route.remove('js/schedule.js');
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user