# cssproc

> CSS URL processor

Latest version **0.0.7** (published 2013-07-19) · 0 weekly downloads

## Install

```sh
npm install cssproc
pnpm add cssproc
yarn add cssproc
bun add cssproc
```

## 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.0.7 |
| Published | 2013-07-19 |
| First published | 2013-02-07 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Dav Glass |
| Maintainers | davglass, ericf, caridy |
| Keywords | css, processor, combohandler |

## Links

- npm: https://www.npmjs.com/package/cssproc
- Repository: http://github.com/davglass/cssproc
- Issues: http://github.com/davglass/cssproc/issues
- npm.io page: https://npm.io/package/cssproc

## 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.0.7 (latest) — 2013-07-19
- 0.0.6 — 2013-07-19
- 0.0.5 — 2013-07-19
- 0.0.4 — 2013-07-19
- 0.0.3 — 2013-07-15
- 0.0.2 — 2013-07-15
- 0.0.1 — 2013-02-07

## README

CSS Relative URL Processor
==========================

A small module designed to convert relative asset URL's in CSS files into absolute URL's for deployment
to a combo handled CDN (yui.yahooapis.com).

When you request a CSS file from a server with a ComboHandler on it, relative CSS assets are broken by default.

If your CSS looks like this:

```css
.foo {
    background-image: url( foo.png );
}
```

Located in a file with this path: `foo/bar/baz/main.css`

Loaded from a ComboHandler like this: `/combo?foo/bar/baz/main.css`

Your Image will resolve to: `/combo/foo.png`

When it should resolve to: `/foo/bar/baz/foo.png`

That's what this module does!


Build Status
------------

[![Build Status](https://secure.travis-ci.org/davglass/cssproc.png?branch=master)](http://travis-ci.org/davglass/cssproc)

Install
-------

    npm install cssproc


Examples
--------

As a file (from `examples/file/`):

```javascript
var cssproc = require('../../lib'),
    path = require('path'),
    fs = require('fs');

var file = path.join(__dirname, 'a1/f1/f2/test.css');

fs.readFile(file, 'utf8', function(err, data) {
    cssproc.parse({
        root: __dirname,
        path: file,
        base: 'http://yui.yahooapis.com/gallery-123456/'
    }, data, function(err, str) {
        console.log(str);
    });
});
```

It could also be used inside of a [combo handler](https://github.com/rgrove/combohandler)

Base
----

The value of `base` could be:

* `http://foobar.com/path/to` where protocol will be forced to HTTP
* `https://foobar.com/path/to` where protocol will be forced to SSL
* `//foobar.com/path/to` which is protocol agnostic where it uses the protocol for the css file that contains the images.
* `/path/to` for absolute paths where it uses the domain and protocol from the css file that contains the images.
* `['http://server1.com/path/to', '//server2.com/path/to', etc]` an array of hosts to loop through and alternate in the file to support domain sharding.

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