UNPKG

maplibre-gl

Version:

BSD licensed community fork of mapbox-gl, a WebGL interactive maps library

26 lines (20 loc) 665 B
import {Plugin} from 'rollup'; function replacer(key: string, value: any) { return (key === 'doc' || key === 'example' || key === 'sdk-support') ? undefined : value; } export default function minifyStyleSpec(): Plugin { return { name: 'minify-style-spec', transform: (source, id) => { if (!/style\-spec[\\/]reference[\\/]v[0-9]+\.json$/.test(id)) { return; } const spec = JSON.parse(source); delete spec['expression_name']; return { code: JSON.stringify(spec, replacer, 0), map: {mappings: ''} }; } }; }