plotly/plotly.js

Strip down bundled Maplibre CSS

Opened this issue · 1 comments

#7526 inlines the entire maplibre-gl.css stylesheet into the Plotly.js bundle, to fix the styling of attributions in MapLibre.

This works, but also adds about 45 kB to the bundle size. Plausibly we could slim down the CSS and include only the styles we definitely need.

This file (4 kB) is enough to fix the attribution styling:

maplibre-gl-attrib.css

However this will require adding a script to parse and subset the CSS which runs as part of the build process.

I use plotly in a vite-bundled website like so:

import Plotly from "plotly.js/lib/core.js";
import scatter from "plotly.js/lib/scatter";
import table from "plotly.js/lib/table";

Plotly.register([scatter, table]);

As you can see, I'm not using any map functionality, but I can see the maplibre css in my bundle. Is there any way of excluding this?