UNPKG

665 BPlain TextView Raw
1import {Plugin} from 'rollup';
2
3function replacer(key: string, value: any) {
4 return (key === 'doc' || key === 'example' || key === 'sdk-support') ? undefined : value;
5}
6
7export default function minifyStyleSpec(): Plugin {
8 return {
9 name: 'minify-style-spec',
10 transform: (source, id) => {
11 if (!/style\-spec[\\/]reference[\\/]v[0-9]+\.json$/.test(id)) {
12 return;
13 }
14
15 const spec = JSON.parse(source);
16
17 delete spec['expression_name'];
18
19 return {
20 code: JSON.stringify(spec, replacer, 0),
21 map: {mappings: ''}
22 };
23 }
24 };
25}