Rollup Rebase


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.
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.
Features
- 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 Smart Import into the origin files. - Renames all assets based on their hash (SHA256 + Base62) so that conflicts are automatically eliminated while producing a flat zero depth output structure.
- Supports normal CSS, but also SugarSS, SCSS and Sass via the standard PostCSS parser plugins.
- Processes all files which do not match this extension list:
.jsx
, .js
, .tsx
, .ts
, .json
, .vue
.
Installation
$ npm install --save-dev rollup-plugin-rebase
or
$ yarn add --dev rollup-plugin-rebase
Usage
Rollup rebase comes with a binary which can be called from within your scripts
section
in the package.json
file.
import rebasePlugin from "rollup-plugin-rebase"
const outputFolder = "./lib";
const rebase = rebasePlugin({ outputFolder })
rollup({
entry: entry,
...
external: rebase.isExternal,
...
plugins: [
...
rebase
]
})
.then((bundle) =>
bundle.write({
...
dest: `${outputFolder}/index.js`
})
)
Copyright
Copyright 2016-2017
Sebastian Software GmbH