# broccoli-asset-rewrite

> broccoli plugin to rewrite a source tree from an asset map.

Latest version **3.0.0** (published 2020-11-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install broccoli-asset-rewrite
pnpm add broccoli-asset-rewrite
yarn add broccoli-asset-rewrite
bun add broccoli-asset-rewrite
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2020-11-30 |
| First published | 2014-07-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 10.* \|\| 12.* \|\| >= 14 |
| Dependencies | 1 |
| Unpacked size | 15.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Rick Harrison |
| Maintainers | rickharrison, nathanhammond, rwjblue, turbo87, stefanpenner |
| Keywords | broccoli, broccoli-plugin, asset, rewrite, fingerprint |

## Links

- npm: https://www.npmjs.com/package/broccoli-asset-rewrite
- Repository: https://github.com/ember-cli/broccoli-asset-rewrite
- Issues: https://github.com/ember-cli/broccoli-asset-rewrite/issues
- npm.io page: https://npm.io/package/broccoli-asset-rewrite

## Dependencies (1)

- [broccoli-filter](https://npm.io/package/broccoli-filter.md) ^1.2.3

## Recent versions

- 3.0.0 (latest) — 2020-11-30
- 2.0.0 — 2018-08-13
- 1.1.0 — 2016-09-13
- 1.0.15 — 2016-08-09
- 1.0.14 — 2016-07-12
- 1.0.13 — 2016-06-30
- 1.0.12 — 2016-06-18
- 1.0.11 — 2015-12-22
- 1.0.10 — 2015-12-20
- 1.0.9 — 2015-08-02
- 1.0.8 — 2015-06-20
- 1.0.7 — 2015-05-27
- 1.0.6 — 2015-05-27
- 1.0.5 — 2015-04-01
- 1.0.4 — 2015-01-15
- … 6 more at https://npm.io/package/broccoli-asset-rewrite/versions

## README

# broccoli-asset-rewrite

[![npm](https://img.shields.io/npm/v/broccoli-asset-rewrite.svg)](https://www.npmjs.com/package/broccoli-asset-rewrite)

[Broccoli](https://github.com/broccolijs/broccoli) plugin to rewrite a source node from an asset map.

Turns

```
<script src="assets/appname.js">
background: url('/images/foo.png');
```

Into

```
<script src="https://subdomain.cloudfront.net/assets/appname-342b0f87ea609e6d349c7925d86bd597.js">
background: url('https://subdomain.cloudfront.net/images/foo-735d6c098496507e26bb40ecc8c1394d.png');
```

## Installation

```js
npm install broccoli-asset-rewrite --save-dev
```

## Usage

The asset map should have keys of the original names and values of the new names.

```js
var AssetRewrite = require('broccoli-asset-rewrite');

var generatedMap = {
  'assets/appname.css': 'assets/appname-d1d59e0fdcfc183415ab0b72a4f78d9c.css',
  'assets/appname.js': 'assets/appname-ed50537fcd5a71113cf79908f49e854d.js',
  'assets/vendor.css': 'assets/vendor-d41d8cd98f00b204e9800998ecf8427e.css',
  'logo.png': 'logo-c4ab8191636f0a520d1f7f7a82c455a3.png'
};

var assetNode = new AssetRewrite(node, {
  assetMap: generatedMap,
  replaceExtensions: ['html', 'js', 'css'],
  prepend: 'https://subdomain.cloudfront.net/'
});
```

## Options

  - `assetMap` - Default: `{}` - The asset map to rewrite source from.
  - `replaceExtensions` - Default: `['html', 'css']` - The file types to replace source code with new checksum file names.
  - `prepend` - Default: `''` - A string to prepend to all of the assets. Useful for CDN urls like `https://subdomain.cloudfront.net/`
  - `ignore` - Default: `[]` - Ignore files from being rewritten.
  - `annotation` - Default: null - A human-readable description for this plugin instance.
  - `enableCaching` - Default: false - Setting to true will enable caching but may cause problems in typical usage with broccoli-asset-rev.

## Requirements

Node 10 or higher

[![ghit.me](https://ghit.me/badge.svg?repo=rickharrison/broccoli-asset-rewrite)](https://ghit.me/repo/rickharrison/broccoli-asset-rewrite)

## Contributors

Originally authored by [@rickharrison](https://github.com/rickharrison)

---
_Source: https://npm.io/package/broccoli-asset-rewrite · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
