CLI node app that let you minimize an HTML file, keep special comments, and keep Responsys functions intact.
Usage: rsys-minimize
npm install -g rsys-minimize
Note: You must install this package globally to be able to use it anywhere from the CLI.
rsys-minimize C:\work\filename.htm
The resulted minimized file will be created and saved in the same folder with .min
added to the name, like filename.min.htm
.
Use it from inside VSCode as a task
Configure a custom task in VSCode to minimize the current opened file.
Here is an example task file that add the tasks rsys-minimize.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "rsys-minimize",
"type": "shell",
"command": "rsys-minimize ${file}",
"presentation": {
"reveal": "never"
}
}
]
}
Plain HTML comments will get removed.
<!-- REMOVE THIS -->
Special comments starting with double asterisk will not be removed.
<!--** KEEP THIS -->
IE conditional comments will not be removed.
<!--[if IE 6]>KEEP THIS TOO<![endif]-->
<!--[if !IE]> -->ALSO KEEP THIS<!-- <![endif]-->
Any RSYS function found inside an HTML comment will be extracted and preserverd in the code.
From this...
<!-- This is an example of a test string
$setglobalvars(my_var, "test string")$
-->
To this...
$setglobalvars(my_var, "test string")$