简体   繁体   中英

Django on Heroku, issue with Yuglify and CollectStatic

I'm using Django-Pipeline to minify my javascript. When I push my project to Heroku and CollectStatic runs, it gives me the error

pipeline.exceptions.CompressorError: /usr/bin/env: yuglify: No such file or directory

But when I run CollectStatic manually, Yuglify runs without issue. I'm unable to find out the problem. What code should I even show you guys in this situation?

My solution to this was to add a "yuglify" part to the codebase here: https://github.com/nigma/heroku-django-cookbook

Here's my code:

bin/install_yuglify

#!/usr/bin/env bash
set -eo pipefail
npm install -g yuglify

Then add the following to bin/post_compile (around line 23...)

if [ -f bin/install_yuglify ]; then
    echo "-----> Running install_yuglify"
    chmod +x bin/install_yuglify
    bin/install_yuglify
fi

And you should be good to go :)

You can see my code here, for reference: https://github.com/GK-12/rpi_csdt_community/tree/master/bin

Good luck!

I managed to solve the problem with a less painful solution. Heroku provides you with buildpacks, which actually is the environment that your applications is going to build upon. By default you have the python buildpack. That is the reason why the system is able to run commands like python manage.py.... My solution is the following: 1) Install nodejs buildpack as the first buildpack

heroku buildpacks:add --index 1 heroku/nodejs

2) Add the package.json in the same path like requirements.txt 3) In the package.json add the dependency of yuglify

An other solution, is to change your compressions and use a python-written one.

PIPELINE['CSS_COMPRESSOR']  = 'pipeline.compressors.cssmin.CSSMinCompressor'
PIPELINE['JS_COMPRESSOR'] = 'pipeline.compressors.jsmin.JSMinCompressor'

pip install cssmin jsmin

I dont have a clear opinion which is better jsmin or yuglify.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM