The Rollup Rebase Plugin copies static assets as required from your JavaScript code to the destination folder and adjusts the references in there to point to the new location. It also respects assets referenced from your CSS/SCSS files.
- Copies over asset files references from JavaScript into the given output folder.
- Adjust asset references in the output JavaScript files to map to the relative new location.
- Transforms CSS files to inline all includes from
@import
via PostCSS Import into the origin files. - Detects and processes assets referenced from both, JavaScript and CSS.
- Renames all assets based on their hash (XXHash + Base62) so that conflicts are automatically eliminated while producing a flat output structure.
- Supports normal CSS, but also SugarSS, SCSS and Sass via the standard PostCSS parser plugins.
The plugin is meant as a tool for preparing a library for being published. In this it differs from plugins like Rollup URL Plugin as it is designed for usage in libraries and not for applications. The output of this plugin can be used by tools like Webpacks File Loader, URL Loader or the already mentioned Rollup URL Plugin.
$ npm install --save-dev rollup-plugin-rebase
or
$ yarn add --dev rollup-plugin-rebase
You can configure Rollup Rebase as part of your Rollup configuration. This can be either done in a rollup.config.js
or by scripting using the Rollup API:
import { rollup } from "rollup"
import rebasePlugin from "rollup-plugin-rebase"
async function config() {
const bundle = await rollup({
input: "./src/index.js",
plugins: [rebasePlugin()]
})
await bundle.write({
dest: "./lib/index.js"
})
}
config()
assetFolder
: When set assets are placed inside a sub folder with that name.keepName
: Iftrue
, generated filenames will be${filename}~${hash}.${ext}
instead of just${hash}.${ext}
verbose
: Iftrue
, increases log levelinclude
: Standard include option for rollup plugins.exclude
: Standard exclude option for rollup plugins.
Copyright 2016-2022
Sebastian Software GmbH