aabmets/rollup-plugin-pull-remote-blob(新しいタブで開きます)
主要言語: TypeScript
Rollup plugin for downloading arbitrary remote files into any local directory on project build time
- star 数
- 2
- watcher 数
- 1
- fork 数
- 0
- issue 数
- 0
- 最終更新
- 2025/03/10
主要言語: TypeScript
Rollup plugin for downloading arbitrary remote files into any local directory on project build time
rollup-plugin-pull-remote-blob is a Rollup plugin designed to download remote files (blobs) during the build process.
It allows you to specify remote resources, manage caching, and handle automatic decompression of downloaded archives.
Because Vite is built on Rollup, you can also use this plugin in Vite projects.
npm install rollup-plugin-pull-remote-blob --save-dev
bun add rollup-plugin-pull-remote-blob --dev
You can configure the plugin to download files as part of your Rollup build configuration. This plugin can be used with or without TypeScript; the types are handled automatically. Here is an example with all explained config options of how to use this plugin in your Rollup configuration:
import { rollup } from 'rollup'; import { pullRemoteBlobPlugin } from 'rollup-plugin-pull-remote-blob'; import type { PluginConfig, DecompressionOptions } from 'rollup-plugin-pull-remote-blob'; rollup({ input: 'src/index.js', plugins: [ pullRemoteBlobPlugin({ haltOnError: true, // should other waiting downloads be halted when an error is encountered? Default is true showProgress: true, // should download progress bars be displayed in the console? Default is true rollupHook: "closeBundle", // during which Rollup stage the plugin should be executed? Default is "closeBundle" blobs: [ { url: 'https://example.com/data.json', dest: './dist/data.json', // relative paths are supported alwaysPull: true, // useful for when the remote file contents are guaranteed to change prettyName: "Market Data" // Alternate name to display in progress display instead of 'data.json' }, { url: 'https://example.com/some-asset.zip', dest: 'C:/Projects/my_project/dist/assets', // absolute paths are also supported decompress: true, // the files are extracted into the structure they have in the archive sizeBytes: 345000 // Override for when the plugin is unable to determine the remote file size }, { url: 'https://example.com/some-asset.zip', dest: './dist/assets.zip', // will raise an error; path must be a directory when decompressing decompress: { strip: 3, // flatten the file structure when decompressing the archive by amount levels filter: [ // can use a list of strings or RegExp objects to filter archive contents "src/main.js", "package.json", /^\w\d{3}.txt/, ], } } ] }) ] }).then(bundle => { // Output options... });
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.