2

django-pipeline用来管理我的静态资产并编译我的咖啡脚本和 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',
    }
}

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

4

1 回答 1

3

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

于 2013-11-01T17:44:42.460 回答