Gathering detailed insights and metrics for postcss-url-resolver
Gathering detailed insights and metrics for postcss-url-resolver
Gathering detailed insights and metrics for postcss-url-resolver
Gathering detailed insights and metrics for postcss-url-resolver
PostCSS plugin that resolves urls (CSS imports and images) via http requests. Isomorphic (node + browser).
npm install postcss-url-resolver
Typescript
Module System
Node Version
NPM Version
66.9
Supply Chain
97.7
Quality
74.9
Maintenance
50
Vulnerability
99.6
License
JavaScript (98.2%)
CSS (1.8%)
Total Downloads
6,632
Last Day
2
Last Week
2
Last Month
13
Last Year
108
MIT License
1 Stars
9 Commits
1 Branches
1 Contributors
Updated on Apr 15, 2018
Minified
Minified + Gzipped
Latest Version
0.0.1
Package Id
postcss-url-resolver@0.0.1
Size
4.38 kB
NPM Version
5.4.2
Node Version
8.8.1
Cumulative downloads
Total Downloads
3
3
PostCSS plugin that resolves urls (CSS imports and images) via http requests.
This plugin is a combination of postcss-import-url
, postcss-url-mapper
and postcss-base64
. It borrows code from all of them and adds some extra features.
Features:
@import
and url(...)
of remote files.Requirements:
Promise
or a polyfill.Examples:
1/* http://some.remote/file.css */ 2 3@import "http://fonts.googleapis.com/css?family=Tangerine"; 4 5.bar { 6 color: green; 7 background-image: url('./img/logo.svg'); 8}
1/* Input example */ 2 3.foo { 4 color: red; 5} 6 7@import url('http://some.remote/file.css'); 8 9.baz { 10 color: blue; 11}
1/* Output example */ 2 3.foo { 4 color: red; 5} 6 7@font-face { 8 font-family: 'Tangerine'; 9 font-style: normal; 10 font-weight: 400; 11 src: local('Tangerine'), url(http://fonts.gstatic.com/s/tangerine/v7/HGfsyCL5WASpHOFnouG-RKCWcynf_cDxXwCLxiixG1c.ttf) format('truetype') 12} 13 14.bar { 15 color: green; 16 background-image: url('http://some.remote/img/logo.svg'); 17} 18 19.baz { 20 color: blue; 21}
If options.base64
was specified (true
), the background-image
would look like:
1.bar { 2 color: green; 3 background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHNZz4='); 4}
This plugin is isomorphic (Node + browser environments). For sake of versatility, it does not bundle any http-request package. Therefore, it must be provided as a parameter.
1var postcss = require('postcss'); 2var urlResolver = require('postcss-url-resolver'); 3var hh = require('http-https'); 4 5postcss([urlResolver({ 6 exclude: /theme.css$/, 7 base64: true, 8 9 request: function(opt) { 10 return new Promise(function executor(resolve, reject) { 11 var req = hh.get(reqOptions, function(res) { 12 var body = ''; 13 14 res.on('data', function(chunk) { 15 body += chunk.toString(); 16 }); 17 18 res.on('end', function() { 19 resolve(body); 20 }); 21 }); 22 23 req.on('error', reject); 24 req.end(); 25 }); 26 } 27})])
1import postcss from 'postcss'; 2import urlResolver from 'postcss-url-resolver'; 3import axios from 'axios'; 4 5postcss([ urlResolver({ 6 exclude: /theme.css$/, 7 base64: true, 8 9 request: function(opt) { 10 return axios.get(opt.href) 11 .then(res => res.data); 12 } 13})])
Note: axios
can also be used in Node environments.
request
: Function called to make an HTTP request. It gets a parsed URL object as its only parameter. Must return a promise which resolves to the response body (content). Required.recursive
: Whether @import
should be resolved recursively. Default true
.base64
: Resolves and inlines images in base 64. Default false
.exclude
: A RegExp matching urls that won't be resolved. Default null
.See PostCSS docs for examples for your environment.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/9 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
68 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreLast Day
0%
2
Compared to previous day
Last Week
-50%
2
Compared to previous week
Last Month
116.7%
13
Compared to previous month
Last Year
-27.5%
108
Compared to previous year