# postcss-urlrewrite

> PostCSS plugin for easy url() rewriting.

Latest version **0.3.0** (published 2024-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-urlrewrite
pnpm add postcss-urlrewrite
yarn add postcss-urlrewrite
bun add postcss-urlrewrite
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2024-08-12 |
| First published | 2014-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16 |
| Dependencies | 1 |
| Unpacked size | 17.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Maintainers | iadramelk |
| Keywords | postcss, css |

## Links

- npm: https://www.npmjs.com/package/postcss-urlrewrite
- Repository: https://github.com/iAdramelk/postcss-urlrewrite
- Homepage: https://github.com/iAdramelk/postcss-urlrewrite#readme
- Issues: https://github.com/iAdramelk/postcss-urlrewrite/issues
- npm.io page: https://npm.io/package/postcss-urlrewrite

## Dependencies (1)

- [postcss-helpers](https://npm.io/package/postcss-helpers.md) ^0.3.3

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2024-08-12
- 0.2.2 — 2017-08-30
- 0.2.1 — 2017-01-05
- 0.2.0 — 2015-12-20
- 0.1.1 — 2014-08-13

## README

## postcss-urlrewrite [![Build Status](https://secure.travis-ci.org/iAdramelk/postcss-urlrewrite.png)](https://travis-ci.org/iAdramelk/postcss-urlrewrite)

> PostCSS plugin for easy url() rewriting.

### Getting Started


```shell
npm install postcss-urlrewrite
```

### Example

Usage example:

```javascript
// dependencies
var fs = require( 'fs' );
var postcss = require( 'postcss' );
var urlrewrite = require( 'postcss-urlrewrite' );

// css to be processed
var css = fs.readFileSync( 'build/build.css', 'utf8' );

// config for urlrewrite
var config = {
    imports: true,
    properties: [ 'background', 'content' ],
    rules: [
        { from: \local\, to: 'global' },
        { from: \local2\, to: 'global2' }
    ]
};

// process css using postcss-urlrewrite
var out = postcss()
   .use( urlrewrite( config ) )
   .process( css )
   .css;
```

### Configuration

#### imports

**Type**: boolean
**Default**: false

If set to true will replace urls in **@import** at-rules.

#### properties

**Type**: array or boolean
**Default**: true

List of css-properties to replace. If set to true, will work with all
properties. If set to array will work only with the properties in the list.

#### rules

**Type**: array of objects or function

There is to way to set rules:

1. Create array of objects with "from" and "to" keys. "from" can be **String** or **RegExp**, "to" can be **String** or **Function**. See [String.replace()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) syntax for details. ONLY first matching rule will be triggered on each URI.
2. Create function that will work with [URIjs](http://medialize.github.io/URI.js/) objects and mutate them one way or another.

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