Registry / devops / gulp-css-urlencode-inline-svgs

gulp-css-urlencode-inline-svgs

JSON →
library0.0.7jsnpmunverified

A Gulp plugin that URL-encodes inline SVG data URIs in CSS to ensure cross-browser compatibility, particularly for Firefox and IE. It transforms data:image/svg+xml;utf8 URIs by percent-encoding characters like <, >, " to prevent parsing issues. Version 0.0.7 is the latest and appears to be stable with low release activity. It operates on plain CSS, intended to be used after CSS preprocessing and autoprefixing but before minification. The plugin is minimal, focusing solely on encoding SVGs, with no other transformations, making it a focused tool for a specific problem.

npm install gulp-css-urlencode-inline-svgs
INSTALL
IMPORT
SIG · GULP-CSS-URLENCODE
G
gulp-css-urlencode-inline-svgs
devopsjavascriptv0.0.7
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 (function)
const urlencode = require('gulp-css-urlencode-inline-svgs');
import urlencode from 'gulp-css-urlencode-inline-svgs';
Package is CommonJS-only; ESM import will fail.

Complete Gulp task that compiles SCSS, adds vendor prefixes, URL-encodes inline SVGs, then minifies CSS.

const gulp = require('gulp'); const sass = require('gulp-sass'); const autoprefixer = require('gulp-autoprefixer'); const urlencode = require('gulp-css-urlencode-inline-svgs'); const cssmin = require('gulp-cssmin'); gulp.task('styles', function () { return gulp.src('src/styles/**/*.scss') .pipe(sass()) .pipe(autoprefixer()) .pipe(urlencode()) .pipe(cssmin()) .pipe(gulp.dest('dist')); });
Debug
Known issues
gotchaPackage only processes SVG data URIs with the utf8 parameter; other formats like base64 are ignored.
fix
Ensure your inline SVGs use format: data:image/svg+xml;utf8, ...
affects: all
gotchaThe plugin does not detect SVG URIs encoded as base64 or without the utf8 parameter.
fix
Convert base64 SVGs to utf8 format before using this plugin.
affects: all
deprecatedThe package uses gulp-util which is deprecated in Gulp 4.x. It may still work but is not recommended for new projects.
fix
Consider forking or switching to a modern alternative like gulp-replace with a custom regex.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: gulp is not a function
Using gulp 4 with older code patterns.
fix
Update to gulp 4 syntax: exports.task = ... instead of gulp.task(...)
Upgrade
Version history
0.0.7latest on npm
Audit
Dependencies
through2requiredstream transformation
gulp-utiloptionalplugin utilities
Agent activity
4 hits · last 30 days
node
4
Resources
gulp-css-urlencode-inline-svgs — npm install gulp-css-urlencode-inline-svgs · libregistry