Skip to content

Instantly share code, notes, and snippets.

@alexantr
Last active January 25, 2023 13:52
Show Gist options
  • Save alexantr/3d2247ff8dc5a7b9c1af38af9e2312f8 to your computer and use it in GitHub Desktop.
Save alexantr/3d2247ff8dc5a7b9c1af38af9e2312f8 to your computer and use it in GitHub Desktop.
@echo off
REM Minify JS CSS SVG
REM npm install uglify-js -g
REM or
REM npm install terser -g
REM npm install clean-css-cli -g
REM npm install svgo -g
setlocal enabledelayedexpansion
set in_path="%~dpnx1"
set out_path="%~dpn1.min%~x1"
set ext=%~x1
set script_path=%~dp0
if /I %ext%==.js (
echo File is JS
call uglifyjs %in_path% -c -m -o %out_path%
)
if /I %ext%==.css (
echo File is CSS
call cleancss -o %out_path% %in_path%
)
if /I %ext%==.svg (
echo File is SVG
rem call svgo --enable=convertStyleToAttrs --disable=removeViewBox --multipass %in_path%
call svgo --config="%~dp0svgo.config.js" %in_path%
)
timeout 2 > NUL
module.exports = {
multipass: true,
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
'convertStyleToAttrs',
'sortAttrs',
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment