#!/bin/bash # Copyright 2020 Netsyms Technologies. # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # This script removes some stuff in `www/node_modules` that the app doesn't need to run. # It removes about 6MB from the build size. echo "Removing bloat in node_modules..." # exit when any command fails # this script nuked my home folder once, hopefully it won't happen again now. set -e DIR="$(pwd)/www/node_modules" cd $DIR rm -rf buffer-from rm -rf concat-stream rm -rf csscolorparser rm -rf dom7 rm -rf earcut rm -rf geojson-vt rm -rf gl-matrix rm -rf grid-index rm -rf ieee754 rm -rf inherits rm -rf kdbush rm -rf list rm -rf @mapbox rm -rf minimist rm -rf murmurhash-js rm -rf path-to-regexp rm -rf pbf rm -rf potpack rm -rf protocol-buffers-schema rm -rf quickselect rm -rf readable-stream rm -rf resolve-protobuf-schema rm -rf rw rm -rf safe-buffer rm -rf ssr-window rm -rf string_decoder rm -rf supercluster rm -rf template7 rm -rf tinyqueue rm -rf typedarray rm -rf util-deprecate rm -rf vt-pbf # Make npm stop complaining that these don't exist by actually removing them rm -rf .bin/* cd @fortawesome/fontawesome-pro rm -rf {js,less,metadata,scss,sprites,svgs} find css -type f -not -name 'all.min.css' -delete cd $DIR cd framework7 rm -rf components rm -rf lazy-components rm -rf less rm -rf modules rm -rf utils rm -f framework7.* rm -f framework7-lite.* find css -type f -not -name 'framework7.bundle.min.css' -delete find js -type f -not -name 'framework7.bundle.min.js' -delete cd $DIR cd framework7-icons rm -rf svg cd $DIR cd jquery rm -rf src rm -rf external find dist -type f -not -name 'jquery.min.js' -delete cd $DIR cd leaflet rm -rf {CHANGELOG.md,src} find dist -type f -not -name 'leaflet.css' -not -name 'leaflet.js' -delete cd $DIR cd leaflet.locatecontrol rm -rf {CHANGELOG.md,README.md,src} find dist -type f -not -name 'L.Control.Locate.min.css' -not -name 'L.Control.Locate.min.js' -delete cd $DIR cd leaflet.markercluster rm -rf {build,example,spec,src,CHANGELOG.md} find dist -type f -not -name 'leaflet.markercluster.js' -not -name 'MarkerCluster.css' -not -name 'MarkerCluster.Default.css' -delete cd $DIR cd material-design-icons # Remove everything except the icon font and license, but also exclude the # current and parent folder (. , ..) so rm won't complain about refusing # to delete the whole filesystem find . -maxdepth 1 -not -name '.' -not -name 'LICENSE' -not -name 'iconfont' -exec rm -rf {} \; cd $DIR cd mapbox-gl rm -rf {build,flow-typed,src} find dist -type f -not -name 'mapbox-gl.css' -not -name 'mapbox-gl.js' -delete rm -rf dist/style-spec cd $DIR echo "Cleanup finished"