【问题标题】:Django Pipeline generates empty fileDjango Pipeline 生成空文件
【发布时间】:2015-10-22 20:02:48
【问题描述】:

我有一个新的 Django 项目,似乎一切正常。我正在使用 Django 管道,但是当我运行“collectstatic”命令时,它会生成所有文件,但我的主要 css 和 js 文件是空白的,js 文件包含...

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

但是没有我的代码。这是我的设置:

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',
    }
}

【问题讨论】:

    标签: python django assets django-pipeline


    【解决方案1】:

    所有都在本地工作,但是当我在生产中尝试“colectstatic”命令时,它只会生成空白文件。它现在可以工作了,我没有在我的生产文件设置中指定我的“STATICFILES_DIRS”。

    STATIC_URL = '/static/'
    
    STATIC_ROOT = '/var/location/to/your/static/files'
    
    STATICFILES_DIRS = (
        os.path.join(BASE_DIR, "static"),
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-19
      • 2021-11-24
      • 2014-07-18
      相关资源
      最近更新 更多