Browse Source

Add prebuild node_modules cleanup script to reduce package size

master
Skylar Ittner 2 years ago
parent
commit
6e740f54f7
  1. 3
      .gitignore
  2. 2
      config.xml
  3. 2
      nbproject/project.properties
  4. 39
      scripts/clean_node_modules.sh
  5. 3
      www/index.html
  6. 3
      www/package.json
  7. 5
      www/yarn.lock

3
.gitignore

@ -3,4 +3,5 @@
/platforms
/hooks
/node_modules
/www/node_modules
/www/node_modules
nbproject/private

2
config.xml

@ -26,6 +26,8 @@
<icon background="res/android/mipmap-xxhdpi/ic_launcher_background.png" density="xxhdpi" foreground="res/android/mipmap-xxhdpi/ic_launcher_foreground.png" src="res/android/mipmap-xxhdpi/ic_launcher.png" />
<icon background="res/android/mipmap-xxxhdpi/ic_launcher_background.png" density="xxxhdpi" foreground="res/android/mipmap-xxxhdpi/ic_launcher_foreground.png" src="res/android/mipmap-xxxhdpi/ic_launcher.png" />
<hook type="after_prepare" src="scripts/clean_node_modules.sh" />
</platform>
<platform name="ios">
<allow-intent href="itms:*"/>

2
nbproject/project.properties

@ -19,4 +19,4 @@ project.licensePath=./nbproject/license-mpl.txt
site.root.folder=${file.reference.Game-www}
source.folder=${file.reference.TerranQuest-Game}
start.file=index.html
web.context.root=/Game
web.context.root=http://localhost/terranquest-game/

39
scripts/clean_node_modules.sh

@ -0,0 +1,39 @@
#!/bin/bash
# Sorry Windows users, upgrade to a better OS
# -- r/linuxmasterrace
cd platforms/android/app/src/main/assets/www/node_modules
echo "Cleaning up node_modules from www..."
echo "Size before: $(du -sh | cut -d ' ' -f 1)"
rm -r {.bin,.yarn-integrity}
rm -r ./{ansicolors,buffer-from,canvas-renderer,cardinal,concat-stream,core-util-is,csscolorparser,dom7}
rm -r ./{earcut,esm,esprima,geojson-vt,gl-matrix,grid-index,ieee754,inherits,isarray,kdbush,@mapbox,minimist,murmurhash-js}
rm -r ./{path-to-regexp,pbf,potpack,process-nextick-args,protocol-buffers-schema,quickselect}
rm -r ./{readable-stream,redeyed,resolve-protobuf-schema,rw,safe-buffer,sharkdown,split,ssr-window,string_decoder}
rm -r ./{supercluster,template7,through,tinyqueue,typedarray,util-deprecate,vt-pbf,wgs84}
rm -r @fortawesome/fontawesome-free/{js,less,scss,sprites,svgs}
rm -r @fortawesome/fontawesome-free/css/{all.css,brands.css,brands.min.css,fontawesome.css,fontawesome.min.css,regular.css,\
regular.min.css,solid.css,solid.min.css,svg-with-js.css,svg-with-js.min.css,v4-shims.css,v4-shims.min.css}
rm -r framework7/{components,less,modules,utils}
rm -r framework7/{framework7.bundle.less,framework7.esm.bundle.d.ts,framework7.esm.bundle.js,framework7.esm.d.ts,framework7.esm.js,framework7.less}
rm -r framework7/css/{framework7.bundle.css,framework7.bundle.rtl.css,framework7.bundle.rtl.min.css,framework7.css,framework7.min.css,framework7.rtl.css,framework7.rtl.min.css}
rm -r framework7/js/{framework7.bundle.d.ts,framework7.bundle.js,framework7.d.ts,framework7.js,framework7.min.js,framework7.min.js.map}
rm -r jdenticon/{src,index.js,dist/jdenticon.js}
rm -r jquery/{external,src}
rm -r jquery/dist/{core.js,jquery.js,jquery.slim.js,jquery.slim.min.js,jquery.slim.min.map}
rm -r mapbox-gl/{build,CHANGELOG.md,flow-typed,node_modules,src}
rm -r mapbox-gl/dist/{mapbox-gl-csp.js,mapbox-gl-csp.js.map,mapbox-gl-csp-worker.js,mapbox-gl-csp-worker.js.map,mapbox-gl-dev.js,\
mapbox-gl-dev.js.flow,mapbox-gl.js.flow,mapbox-gl.js.map,mapbox-gl-unminified.js,mapbox-gl-unminified.js.map,style-spec}
echo "Size after: $(du -sh | cut -d ' ' -f 1)"
echo "Cleanup complete!"

3
www/index.html

@ -31,8 +31,7 @@
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/framework7/js/framework7.bundle.min.js"></script>
<script src="node_modules/mapbox-gl/dist/mapbox-gl.js"></script>
<script src="node_modules/three/build/three.min.js"></script>
<script src="node_modules/three/examples/js/loaders/GLTFLoader.js"></script>
<script src="node_modules/jdenticon/dist/jdenticon.min.js"></script>
<script src="settings.js"></script>
<script src="js/api.js"></script>

3
www/package.json

@ -8,7 +8,6 @@
"framework7": "^4.3.0",
"jdenticon": "^2.1.1",
"jquery": "^3.4.0",
"mapbox-gl": "^0.54.0",
"three": "^0.104.0"
"mapbox-gl": "^0.54.0"
}
}

5
www/yarn.lock

@ -348,11 +348,6 @@ template7@^1.4.1:
resolved "https://registry.yarnpkg.com/template7/-/template7-1.4.1.tgz#c3b2b03d6879e1c5f8a79067c961c8896ffaeec6"
integrity sha512-sYZ9Wl5kFuNSvLcMPq8z4oenG7rDho6KnB2vWyvMJCdI1guJhxTEU0TCwr6Nd1Jx34kSOmrpJakMGxJgCc55yg==
three@^0.104.0:
version "0.104.0"
resolved "https://registry.yarnpkg.com/three/-/three-0.104.0.tgz#9ad1da492153b753a89e0df066631215bd9d9087"
integrity sha512-q617IMBC5k40U2E9UC4/LtmhzTOOLB1jGMIooUL+QrhZ7abiGCSDrKrpCDt9V8RTl6xw+0FYfA1PYsIPKbQOgg==
through@2:
version "2.3.8"
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"

Loading…
Cancel
Save