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.

Revisions

  1. alexantr revised this gist Jan 25, 2023. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions svgo.config.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    module.exports = {
    multipass: true,
    plugins: [
    {
    name: 'preset-default',
    params: {
    overrides: {
    removeViewBox: false,
    },
    },
    },
    'convertStyleToAttrs',
    'sortAttrs',
    ],
    };
  2. alexantr revised this gist Jan 25, 2023. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions minify.bat
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@

    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
    @@ -15,15 +17,16 @@ set script_path=%~dp0

    if /I %ext%==.js (
    echo File is JS
    call terser %in_path% -c -m -o %out_path%
    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
    call svgo --enable=convertStyleToAttrs --disable=removeViewBox --multipass %in_path%
    rem call svgo --enable=convertStyleToAttrs --disable=removeViewBox --multipass %in_path%
    call svgo --config="%~dp0svgo.config.js" %in_path%
    )

    timeout 2 > NUL
  3. alexantr revised this gist Nov 8, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions minify.bat
    Original file line number Diff line number Diff line change
    @@ -14,15 +14,15 @@ set ext=%~x1
    set script_path=%~dp0

    if /I %ext%==.js (
    echo File is JS (using terser)
    echo File is JS
    call terser %in_path% -c -m -o %out_path%
    )
    if /I %ext%==.css (
    echo File is CSS (using cleancss)
    echo File is CSS
    call cleancss -o %out_path% %in_path%
    )
    if /I %ext%==.svg (
    echo File is SVG (using svgo)
    echo File is SVG
    call svgo --enable=convertStyleToAttrs --disable=removeViewBox --multipass %in_path%
    )

  4. alexantr created this gist Nov 8, 2021.
    29 changes: 29 additions & 0 deletions minify.bat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    @echo off

    REM Minify JS CSS SVG

    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 (using terser)
    call terser %in_path% -c -m -o %out_path%
    )
    if /I %ext%==.css (
    echo File is CSS (using cleancss)
    call cleancss -o %out_path% %in_path%
    )
    if /I %ext%==.svg (
    echo File is SVG (using svgo)
    call svgo --enable=convertStyleToAttrs --disable=removeViewBox --multipass %in_path%
    )

    timeout 2 > NUL