Last active
January 25, 2023 13:52
-
-
Save alexantr/3d2247ff8dc5a7b9c1af38af9e2312f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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