Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A js compiler & css minifier with sass compatibility
django.contrib.staticfiles
in INSTALLED_APPS
::
pip install django-shrink
::
INSTALLED_APPS = (
...
'django.contrib.staticfiles',
...
'shrink',
...
)
Optionally if you want to use Sass
_ you need to add the compilation view to
your urls::
# urls.py
urlpatterns = patterns('',
...
(r'', include('shrink.urls')),
...
)
.. note::
The compilation view is only available when DEBUG = True
Define your javascripts and css files in your template as in this example::
{% import shrink %}
{% styles css/myproject-min.css %}
css/reset.css
css/forms.css
css/myproject.scss
{% endstyles %}
{% scripts js/myproject-min.js %}
js/jquery.js
js/plugin.js
js/myproject.js
{% endscripts %}
When DEBUG = True
this will end up as::
<link rel="stylesheet" href="{{ STATIC_URL }}css/reset.css">
<link rel="stylesheet" href="{{ STATIC_URL }}css/forms.css">
<link rel="stylesheet" href="{{ STATIC_URL }}css/myproject.scss">
<script src="{{ STATIC_URL }}js/jquery.js"></script>
<script src="{{ STATIC_URL }}js/plugin.js"></script>
<script src="{{ STATIC_URL }}js/myproject.js"></script>
When DEBUG = False
this will end up as::
<link rel="stylesheet" href="{{ STATIC_URL }}css/myproject-min.css?timestamp">
<script src="{{ STATIC_URL }}js/myproject-min.js?timestamp"></script>
When deploying you want to compile your javascripts, compile your scss (Sass
_)
and compress the css files. django-shrink overrides the collectstatic
management command and after collecting the static files it does the compiling
and compressing. Thus you need to execute the management command
collectstatic
in your deployment environment.
.. note:: As of yet you need all the source css files and the destination minified css file to be in the same path if they ahev relative references to media.
SHRINK_TIMESTAMP ^^^^^^^^^^^^^^^^ Controls if you want to timestamp the compressed/compiled assets.
True
SHRINK_STORAGE ^^^^^^^^^^^^^^ Storage for the compressed/compiled assets.
settings.STATICFILES_STORAGE
SHRINK_CLOSURE_COMPILER ^^^^^^^^^^^^^^^^^^^^^^^ Path to Google Closure Compiler jar.
SHRINK_CLOSURE_COMPILER_COMPILATION_LEVEL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Google Closure Compiler optimization level.
'SIMPLE_OPTIMIZATIONS'
SHRINK_YUI_COMPRESSOR ^^^^^^^^^^^^^^^^^^^^^ Path to YUI Compressor
.. _Sass: http://sass-lang.com/
FAQs
js compiler & css minifier with sass compatibility
We found that django-shrink demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.