1.0.9 • Published 5 days ago

@csstools/postcss-rebase-url v1.0.9

Weekly downloads
-
License
MIT-0
Repository
github
Last release
5 days ago

PostCSS Rebase URL

npm install @csstools/postcss-rebase-url --save-dev

PostCSS Rebase URL rebases url() functions when transforming CSS.

When bundling CSS, the location of the final stylesheet file will be different than the individual source files.
PostCSS Rebase URL rewrites the contents of url() functions so that relative paths continue to work.

Instead of manually mapping where the files will be in the final output you can use this plugin
and simply use the relative paths to each source file.

If you need something with more knobs and dials, please checkout postcss-url

/* when used with a bundler like `postcss-import` */

/* test/examples/example.css */
@import url("imports/basic.css");

/* test/examples/imports/basic.css */
.foo {
	background: url('../../images/green.png');
}

/* becomes */

/* test/examples/example.expect.css */
.foo {
	background: url("../images/green.png");
}

Usage

Add PostCSS Rebase URL to your project:

npm install postcss @csstools/postcss-rebase-url --save-dev

Use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssRebaseURL = require('@csstools/postcss-rebase-url');

postcss([
	postcssRebaseURL(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

PostCSS Rebase URL runs in all Node environments, with special instructions for:

1.0.9

5 days ago

1.0.8

6 days ago

1.0.7

2 months ago

1.0.6

3 months ago

1.0.5

4 months ago

1.0.4

5 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

9 months ago

0.1.0-alpha.0

9 months ago