【问题标题】:Django asset pipelineDjango 资产管道
【发布时间】:2013-11-02 01:44:42
【问题描述】:

我使用django-pipeline 来管理我的静态资产并编译我的coffeescript 和SCSS 文件。我在配置这个 Django 应用程序时遇到问题。我想要实现的是让django-pipeline 从 assets/ 子目录中读取我的咖啡脚本和 SCSS 文件,并将它们编译并压缩到我告诉 Django 提供静态文件的 public/ 子目录中。

作为参考,我的 Django 文件结构如下所示:

DjangoApp
    assets
        coffeescript
        scss
    bin
    configs
    db
    logs
    DjangoApp
    public
        css
        images
        js
    requirements

我当前的 Django 设置如下所示(为简洁起见,省略了无关的内容):

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/public/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    PROJECT_PATH + '/public',
)

# Asset compilers.
PIPELINE_COMPILERS = (
    'pipeline.compilers.coffee.CoffeeScriptCompiler',
    'pipeline.compilers.sass.SASSCompiler'
)

PIPELINE_CSS = {
    'ie': {
        'source_filenames': (
            'scss/ie.scss',
        ),
        'output_filename': 'css/ie.min.css'
    },
    'print': {
        'source_filenames': (
            'scss/print.scss',
        ),
        'output_filename': 'css/print.min.css'
    },
    'screen': {
        'source_filenames': (
            'scss/screen.scss',
            'scss/screen-responsive-768px.scss',
            'scss/screen-responsive-992px.scss',
            'scss/screen-responsive-1200px.scss'
        ),
        'output_filename': 'css/screen.min.css'
    }
}

PIPELINE_JS = {
    'application': {
        'source_filenames': (
          'coffeescript/application.coffee',
        ),
        'output_filename': 'js/application.min.js',
    }
}

也许这个应用程序不能做我想做的事。我应该寻找其他东西吗?

【问题讨论】:

    标签: python django coffeescript sass assets


    【解决方案1】:

    我已经玩了一段时间了,没有运气。但是我从python gearsdjango-gears 中找到了我想要的东西。考虑到我想要实现的是复制 Ruby sprockets 这将是完美的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-09
      • 1970-01-01
      • 1970-01-01
      • 2021-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-10
      相关资源
      最近更新 更多