Skip to content

Visual Studio Code extension to minify Lua source code

License

Notifications You must be signed in to change notification settings

informagico/vscode-lua-minify

Repository files navigation

Lua Minify

This extension helps you to minify on-the-fly any Lua source file.

Version Installs Rating

Feature

  • Minify the whole file
  • Minify all files in current folder
  • Minify selected code
  • Generate minified .min.lua file
  • Generate minified .min.lua for all files in current folder

Usage

Use the command Lua Minify: Minify (current file) to process current file

vscode-lua-minify

Use the command Lua Minify: Minify Selection to process current selection

Use the command Lua Minify: Minify (workspace) to process all files in current file folder

Use the command Lua Minify: Generate .min file (current file) to process current open file and create a minified separate version

Use the command Lua Minify: Generate .min file (workspace) to process current open file and create a minified separate version

Settings

From 0.9.0 new setting has been added to support file exclusion on workspace minification. This setting can prevent the minification of unwanted files (to leave untouched).

An example of the newly added feature:

"vscode-lua-minify.excludeGlobs": [
  "foo.lua",
  "bar.lua"
]

From 0.7.0 new settings has been added to support multiple functionalities.

  • flavour: Identify which package is going to be used to minify the code. Possible values: "luamin" (default), "lua-format" [lua-format supports Luau]
  • renameVariables: Available only if 'lua-format' is selected. Defines if the variables should be renamed
  • renameGlobals: Available only if 'lua-format' is selected. Defines if the globals should be renamed
  • solveMath: Available only if 'lua-format' is selected. Defines if the math should be solved

Here an example of settings.json file:

"vscode-lua-minify.flavour": "lua-format",
"vscode-lua-minify.renameVariables": false,
"vscode-lua-minify.renameGlobals": false,
"vscode-lua-minify.solveMath": false,

Contributions

Feel free to contribute improving this extension and let me know if you find a bug.


Thanks

A huge thanks to Mathias Bynens (@mathiasbynens) for building up luamin that I used as core for this extension. A huge thanks also to Herrtt (@Herrtt) for building up lua-format that I used as core for this extension.