Registry / devops / postcss-absolute-root-url

postcss-absolute-root-url

JSON →
library0.1.3jsnpmunverified

PostCSS plugin that rewrites relative URL paths in CSS/SCSS to absolute URLs using the ROOT_URL environment variable. Version 0.1.3, released 2021. Simple, single-purpose tool for Meteor/Node/Webpack builds. Avoids hard-coded roots per environment. Limited configuration: enables per property. Currently no active development.

npm install postcss-absolute-root-url
INSTALL
IMPORT
SIG · POSTCSS-ABSOLUTE-R
P
postcss-absolute-root-url
devopsjavascriptv0.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import postcssAbsoluteRootUrl from 'postcss-absolute-root-url'
✗ const postcssAbsoluteRootUrl = require('postcss-absolute-root-url')
ESM import is preferred; CommonJS require also works.
postcss
✓ import postcss from 'postcss'; import plugin from 'postcss-absolute-root-url';
✗ import postcss from 'postcss-absolute-root-url'
This plugin is not a replacement for postcss; it must be used as a plugin.
type definitions
✓ // No bundled types; use @types/postcss-absolute-root-url or declare module
✗ // No wrong pattern – lack of types is known
Plugin lacks TypeScript typings; may need manual declaration.

Shows how to use the plugin to replace relative url() in CSS with absolute URL from ROOT_URL environment variable.

import postcss from 'postcss'; import plugin from 'postcss-absolute-root-url'; const css = `.foo { background-image: url(images/foo.jpg); }`; process.env.ROOT_URL = 'https://example.com'; postcss([plugin({ 'background-image': 1 })]) .process(css, { from: undefined }) .then(result => { console.log(result.css); // .foo { background-image: url(https://example.com/images/foo.jpg); } });
Debug
Known issues
gotchaROOT_URL environment variable must be set at build time; runtime changes are not reflected.
fix
Ensure ROOT_URL is set in your build script (e.g., via dotenv or shell).
affects: >=0.0.1
gotchaPlugin only transforms url() references in selected properties; defaults may not include all needed properties.
fix
Explicitly enable necessary properties in options (e.g., 'background-image', 'src').
affects: >=0.0.1
gotchapostcss-easy-import must run before this plugin; otherwise imported files may not be transformed.
fix
Ensure postcss-easy-import is listed first in PostCSS plugins order.
affects: >=0.0.1
deprecatedPackage has not been updated since 2021; may not work with newer PostCSS versions.
fix
Test with your PostCSS version; consider forking or using alternative like postcss-url.
affects: >=10.0.0
Errors
Common errors & fixes
Error: ROOT_URL environment variable not set
Plugin fails when ROOT_URL is undefined
fix
Set process.env.ROOT_URL to your absolute base URL before running PostCSS.
TypeError: Cannot read properties of undefined (reading 'split')
Plugin receives a CSS node without expected structure (e.g., missing value property)
fix
Ensure CSS is valid and plugin is applied after postcss-easy-import and any other transform plugins.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
postcssrequiredpeer dependency for PostCSS plugin
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
postcss-absolute-root-url — npm install postcss-absolute-root-url · libregistry