Minify an Entire Directory While Keeping Element/Style/Script Relationships?

前端 未结 3 1440
北海茫月
北海茫月 2021-02-04 07:27

Do any solutions currently exist that can minify an entire project directory? More importantly, do any solutions exist that can shorten classnames, id\'s, and keep them consiste

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-04 08:10

    I use YUICompressor for minifying my css and js files, and a program called replace to do custom replacement of strings in html(removing comments, replacing local jquery lib with google api etc.)

    Use a batch file to call the program on all the files with a specific extension in your project directory like so:

    java -jar yuicompressor-2.4.2.jar -o temp\css\one-compressed.css temp\css\one.css
    replace -quotes \q -srcdir temp\ -fname "*.php" -find "" -replace ""
    

    and so on.

    So far, I haven't been able to find any good tool for obfuscation. But these two alone make the task of minification and compression automated and much easier.

提交回复
热议问题