combine javascript files at deployment in python

后端 未结 6 2072
一向
一向 2021-01-30 07:41

I\'m trying to reduce the number of scripts included in our website and we use buildout to handle deployments. Has anybody successfully implemented a method of combining and com

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 08:08

    I created Minifpy : a tool to merge and minify JS and CSS file by using Python.

    This tool use a very easy JSON configuration file to define if files must be merge , minify or not :

    {
        "js": {
            "minify_files": [
                {"from": "static/file.js", "to":"static/file.min.js"},
            ],
            "merge_files": [
                {"from" : ["static/file1.js", "static/file2.js"], "to":"static/public.js", "to_min": "static/public.min.js"}
            ]
        },
        "css" : {
            "minify_files": [
                {"from": "static/file.css", "to":"static/file.min.css"},
            ],
            "merge_files": [
                {"from" : ["static/file1.css", "static/file2.css"], "to":"static/public.css", "to_min": "static/public.min.css"}
            ]
        }
    }
    

    Minifpy detect any modifications on JS/CSS files and merge/minify them automatically (useful for development).

提交回复
热议问题