Django:在发布之前自动缩小css / js文件 [英] Django: auto minifying css/js files before release

查看:169
本文介绍了Django:在发布之前自动缩小css / js文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下情况:我想在开发过程中使用未压缩的js / css文件(例如调试js),但是在生产时我想自动切换到该文件的最小化版本。



一些简单的解决方案是放在你的模板中:

 < script src =some_js。{%如果没有调试%} min。{%endif%} js.... 

但这需要manully提供这样的文件存在,并在原始文件更改后进行minifaction manullay。



你如何在项目中完成这个?是否有任何工具?

解决方案

您尝试过 http://code.google.com/p/django-compress/


请参阅 http://djangopackages.com/grids/g/asset -managers / ,可以获得Django的可用资产管理器的完整列表。



如果您已经在使用django-compress,您应该有一个看看升级到django-pipeline,这是一个维护良好的fork,具有很多新功能。我鼓励每个人正在使用django-compress来切换到django-pipeline:* django-pipeline documentation



I have following case: I want to use uncompressed js/css files during development (to debug js for example) but on production I want to switch automatically to minified versions of that files.

some simple solution is to put in your template:

<script src="some_js.{% if not debug %}min.{% endif %}js"....

but this require manully providing that such file exist and to do minifaction manullay after original file change.

How do you accomplish this in your projects? Is there any tool for this?

解决方案

Did you try http://code.google.com/p/django-compress/ ?

See http://djangopackages.com/grids/g/asset-managers/ for a fairly complete list of available asset managers for Django...

If you already are already using django-compress, you should have a look at upgrading to django-pipeline, which is a well maintained fork, with a lot of new features. I encourage everyone to who is using django-compress to switch to django-pipeline instead: * django-pipeline documentation

这篇关于Django:在发布之前自动缩小css / js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆