mission.shrink

shrink the node_modules folder

Usage no npm install needed!

<script type="module">
  import missionShrink from 'https://cdn.skypack.dev/mission.shrink';
</script>

README

mission.shrink

Caution - This will delete / minify / update the files. So please backup your files before run this command.

Init

It will initialize the shrink.json file.

    shrink init

shrink.json file

{
    "path": "./node_modules",
    "unlink": [
        "*.d.ts",
        "*.md",
        "*LICENSE",
        ".npmignore"
    ],
    "pkg": []  # name & main properties are default.
}

  • path: Relative path / full path of the node_modules folder or any folder which contains javascript files. (Note: This tool will minify or delete or modify your files. so use with caution )

  • unlink: Provide the pattern (glob) to delete the files from the given folder.

  • pkg: Declare the property name form the package.json file if it is required for production.

Shrink

it will shrink the node_modules folder based on the shrink.json file.

    shrink [options]

or

    shrink --file shrink.json [options]

or

    shrink -f shrink.json [options]

ex

    shrink -r -c -m -s -v

Options

file

option: file - relative path of shrink.json file.

Alias: -f

Default value: shrink.json

Description:

removeDuplicate

option: removeDuplicate - remove .min.js file if the original file is available in node_modules folder.

Alias: -r

Default value: false

Description:

cleanup

option: cleanup - unlink unnecessary files form the node_modules folder.

Alias: -c

Default value: false

Description:

minify

option: minify - minify all javascript files located in node_modules folder.

Alias: -m

Default value: false

Description:

shrinkPkg

option: shrinkPkg - remove unused properties from package.json file.

Alias: -s

Default value: false

Description:

verbose

option: verbose - view detailed logs.

Alias: -v

Description:

Benifits

This util will reduce the node_modules folder size in docker container for production.