Django Pipeline generates empty file

Issue

I have a new Django project, all seems to work fine. I am using Django pipeline, however when I run “collectstatic” command, it generates all the files but my main css and js files are blank, well the js file contains…

(function(){}).call(this);

But none of my code. Here is my setup:

PIPELINE_YUGLIFY_BINARY = os.path.join(BASE_DIR, 'node_modules/yuglify/bin/yuglify')
(to get above line working, I ran 'ln -s /usr/bin/nodejs /usr/bin/node')

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)

PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'

PIPELINE_CSS = {
    'stylesheets': {
        'source_filenames': (
        'css/base.css',
    ),
        'output_filename': 'css/base.css',
        'extra_context': {
            'media': 'screen,projection',
        },
    },
}

PIPELINE_JS = {
    'scripts': {
        'source_filenames': (
            'js/vendor/jquery.js',
            'js/base.js',
        ),
        'output_filename': 'javascripts/base.js',
    }
}

Solution

All worked locally, but when I tried “colectstatic” command in production it just generated blank files. It’s working now, I was not specifying my “STATICFILES_DIRS” on my production file settings.

STATIC_URL = '/static/'

STATIC_ROOT = '/var/location/to/your/static/files'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)

Answered By – polarcare

Answer Checked By – Clifford M. (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.