I have a static file that is dynamically fetched by the page via the URL I get from file-loader. The loading can take some time, so I want to show a progress bar, but the server doesn't return a Content-Length
so the progress event has total set to 0. I can hardcode the file size, but it would be much better if file-loader exported the actual file size along with its public URL.
Currently:
import FilePath from './LargeFile.dat';
const FileSize = 12345678;
// handle progress event from XMLHttpRequest/axios
function onProgress(e) {
reportProgress(e.loaded / (e.total || FileSize));
}
Would like:
import FileInfo from './LargeFile.dat';
const { path: FilePath, size: FileSize } = FileInfo;
// handle progress event from XMLHttpRequest/axios
function onProgress(e) {
reportProgress(e.loaded / (e.total || FileSize));
}
Is it possible to do with file-loader
or a similar plugin?