-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove internal scripts if minify
is true and the CDN provider is not local
#251
Conversation
The current implement is a bit silly. Does some one have a better implement?
local
minify
is true and the CDN provider is not local
🤔 You yourself have a better implement in #241 (comment) . Like: hexo.route.list().forEach(path => {
if (path.startsWith('js/')) hexo.route.remove(path);
}); |
I am worried that this will break the plugins that add routes into the |
Here is my solution: Object.keys(hexo.theme._processingFiles).forEach(path => {
if (path.startsWith('source/js/')) hexo.route.remove(path.slice(7));
}); |
Tracing how // ...
const localScripts = [];
hexo.theme.addProcessor('js/*', (file) => {
localScripts.push(file.params[0]);
});
hexo.extend.filter.register('after_generate', () => {
// ...
if (theme.vendors.internal !== 'local') {
localScripts.forEach(path => {
hexo.route.remove(path);
});
return;
}
// ...
}); works fine. |
Nice! It works on my blog. |
minify
is true and the CDN provider is not local
minify
is true and the CDN provider is not local
PR Checklist
PR Type
What is the current behavior?
The local scripts are still remained if the CDN provider is not
local
. However, they will have never been used.What is the new behavior?
Remove local scripts if
minify
is true and the CDN provider is not local.How to use?
In NexT
_config.yml
:(The current implement is a bit silly. Does some one have a better implement?)