我正在使用 django-pipeline 来管理我的静态 Assets 并编译我的 coffeescript 和 SCSS 文件。我在配置此 Django 应用程序时遇到问题。我想要实现的是让 django-pipeline 从 assets/子目录中读取我的 coffeescript 和 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 gears 或 django-gears 中找到了我想要的东西。考虑到我想要实现的是复制 Ruby sprockets,这将是完美的。
