Open
Description
It's tricky to do in a plugin, using hooks.
Here is the farther i got, the extensions.json file is created as an asset, bur require('extensions.json')
does not work...
const fs = require('fs');
const download = require('download');
// Plugin downloading the supported extensions from production backend
const pluginName = 'ExtensionsPlugin';
class ExtensionsPlugin {
apply(compiler) {
compiler.hooks.compilation.tap(pluginName, compilation => {
compilation.hooks.additionalAssets.tapAsync(pluginName, callback => {
console.debug('Downloading coverage extensions...');
download('https://coverage.moz.tools/v2/extensions').then(data => {
// Setup downloaded file as asset
let extensions = data.toString('utf-8');
compilation.assets['extensions.json'] = {
source: () => {
return extensions;
},
size: () => {
return extensions.length;
}
};
callback();
});
});
});
}
}