
Research
Security News
Malicious npm Packages Use Telegram to Exfiltrate BullX Credentials
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
leaflet-defaulticon-compatibility
Advanced tools
Retrieve all Leaflet Default Icon options from CSS, in particular all icon images URL's, to improve compatibility with bundlers and frameworks that modify URL's in CSS.
Retrieve all Leaflet Default Icon options from CSS, in particular all icon images URL's, to improve compatibility with bundlers and frameworks that modify URL's in CSS. Demo with webpack (and without this plugin).
Size: < 2kB minified
Note: here, "compatibility" does not refer to browser compatibility, but with build engines and frameworks that modify URL's in CSS, which often conflicts with Leaflet built-in Default Icon images automatic management. See issue Leaflet/Leaflet#4698 for more details.
$ npm install leaflet-defaulticon-compatibility --save
Load this plugin CSS and JS files after Leaflet CSS and JS. Then the Leaflet default icon should automatically work again, even if your build engine or framework modifies the URL's in CSS, typically:
For example for webpack with style-loader + css-loader + file-loader:
import 'leaflet/dist/leaflet.css';
import 'leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.webpack.css'; // Re-uses images from ~leaflet package
import * as L from 'leaflet';
import 'leaflet-defaulticon-compatibility';
This plugin provides 2 similar CSS files:
leaflet-defaulticon-compatibility.css
: use it by default.leaflet-defaulticon-compatibility.webpack.css
: alternative for webpack / bundlers that understand the ~leaflet
syntax to navigate to other packages in node_modules
. This avoids duplicating the images/marker-icon.png
file from leaflet.css
, hence saving some bytes, especially when the images is inlined as DataURI/base64 (even though with gzip compression this should not be an issue).Some bundlers automatically replace url(path)
in CSS by Data URI (aka base64-encoded) image (i.e. url(data:image/png;base64,SOME_DATA)
). That is typically the case of webpack url-loader and Django pipeline.
If your map displays hundreds of Markers using this inlined image as icon, be aware that it will affect the browser performance much more quickly than using a normal URL file.
This plugin also fixes an edge case in Firefox when a user has configured their browser to always override the websites colours.
When that option is set to "Always" in Firefox preferences, all background images are removed. Therefore Leaflet can no longer detect the default icon images path that was clued through CSS .leaflet-default-icon-path
class background-image
rule.
In that case, this plugin will try to use the cursor
rule instead which is not affected by Firefox colours override option. Therefore the plugin CSS duplicates the images path in both background-image
and cursor
rules.
However, if you use this plugin to specify your own icon in CSS, make sure to still use background-image
rule as the first mean to pass your images path, because Internet Explorer always interpretes URL's in cursor
rule as absolute.
leaflet-defaulticon-compatibility is distributed under the BSD 2-clause "Simplified" License, like Leaflet.
FAQs
Retrieve all Leaflet Default Icon options from CSS, in particular all icon images URL's, to improve compatibility with bundlers and frameworks that modify URL's in CSS.
The npm package leaflet-defaulticon-compatibility receives a total of 24,405 weekly downloads. As such, leaflet-defaulticon-compatibility popularity was classified as popular.
We found that leaflet-defaulticon-compatibility demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.
Security News
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.