Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sebastian-software/rollup-plugin-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.
https://github.com/sebastian-software/rollup-plugin-rebase
Last synced: 15 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/sebastian-software/rollup-plugin-rebase
- Owner: sebastian-software
- License: apache-2.0
- Created: 2016-08-21T18:56:32.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T02:26:35.000Z (almost 2 years ago)
- Last Synced: 2024-05-12T17:01:12.377Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 5.84 MB
- Stars: 58
- Watchers: 5
- Forks: 12
- Open Issues: 13
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
- awesome - rebase - Copies and adjusts asset references to new destination-relative location. (Plugins / Output)
README
# Rollup Rebase
[![Sponsored by][sponsor-img]][sponsor] [![Version][npm-version-img]][npm] [![Downloads][npm-downloads-img]][npm] [![Build Status][github-img]][github]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.
[sponsor]: https://www.sebastian-software.de
[npm]: https://www.npmjs.com/package/rollup-plugin-rebase
[sponsor-img]: https://badgen.net/badge/Sponsored%20by/Sebastian%20Software/692446
[npm-downloads-img]: https://badgen.net/npm/dm/rollup-plugin-rebase
[npm-version-img]: https://badgen.net/npm/v/rollup-plugin-rebase
[github]: https://github.com/sebastian-software/rollup-plugin-rebase/actions
[github-img]: https://badgen.net/github/status/sebastian-software/rollup-plugin-rebase?label=tests&icon=github## 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 Import](https://github.com/postcss/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](https://github.com/postcss/sugarss), [SCSS](https://github.com/postcss/postcss-scss) and [Sass](https://github.com/aleshaoleg/postcss-sass) via the standard PostCSS parser plugins.## Comparison
The plugin is meant as a tool for preparing a library for being published. In this it differs from plugins like [Rollup URL Plugin](https://github.com/Swatinem/rollup-plugin-url) 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](https://github.com/webpack/file-loader), [URL Loader](https://github.com/webpack/url-loader) or the already mentioned [Rollup URL Plugin](https://github.com/Swatinem/rollup-plugin-url).
## Installation
```console
$ npm install --save-dev rollup-plugin-rebase
```or
```console
$ yarn add --dev rollup-plugin-rebase
```## Usage
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:
```js
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()
```### Options (all optional)
- `assetFolder`: When set assets are placed inside a sub folder with that name.
- `keepName`: If `true`, generated filenames will be `${filename}~${hash}.${ext}` instead of just `${hash}.${ext}`
- `verbose`: If `true`, increases log level
- `include`: Standard include option for rollup plugins.
- `exclude`: Standard exclude option for rollup plugins.## Copyright
Copyright 2016-2022
[Sebastian Software GmbH](http://www.sebastian-software.de)