@garfish/loader
Usage
import { Loader } from '@garfish/loader';
const loader = new Loader({
maxSize: 1024 * 1024 * 15,
});
loader.hooks.usePlugin({
name: 'test-plugin1',
beforeLoad({ url, config }) {
if (url.includes('xx')) {
url = url.replace('xx', '');
}
return { url, config };
},
loaded(data) {
const { result, value } = data;
data.n = 1;
return data;
},
});
loader.hooks.usePlugin({
name: 'test-plugin2',
loaded(data) {
console.log(data.n);
return data;
},
});
loader.load({scope: 'appName', url: 'https://xxx'}).then((result) => {
console.log(result);
});
Clear cache
const loader = new Loader();
loader.clear('appName');
loader.clear('appName', 'js');
loader.clearAll();
loader.clearAll('css');