在AWS Elastic Beanstalk上使用webassets scss过滤器

时间:2014-06-20 14:36:24

标签: python amazon-web-services sass elastic-beanstalk

Flask-Assets / webassets scss过滤器在我的本地计算机上运行正常,因为我安装了SASS。我的Elastic Beanstalk应用程序中的EC2实例没有,因此它会出错。

   Traceback (most recent call last):
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
  response = self.full_dispatch_request()
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
  rv = self.handle_user_exception(e)
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
  reraise(exc_type, exc_value, tb)
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
  rv = self.dispatch_request()
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
  return self.view_functions[rule.endpoint](**req.view_args)
File "/opt/python/run/venv/lib/python2.7/site-packages/flask_login.py", line 732, in decorated_view
  return func(*args, **kwargs)
File "/opt/python/run/venv/lib/python2.7/site-packages/flask_security/decorators.py", line 194, in decorated_view
  return fn(*args, **kwargs)
File "/opt/python/current/app/app/frontend/prep.py", line 427, in deliveries_outstanding
  ('created_at', 'Added'),
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/templating.py", line 128, in render_template
  context, ctx.app)
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/templating.py", line 110, in _render
  rv = template.render(context)
File "/opt/python/run/venv/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
  return self.environment.handle_exception(exc_info, True)
File "/opt/python/run/venv/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
  reraise(exc_type, exc_value, tb)
File "/opt/python/current/app/app/frontend/templates/prep/_model_list.html", line 4, in top-level template code
  {% from "macros/stickers.html" import render_sticker %}
File "/opt/python/current/app/app/frontend/templates/prep/_master.html", line 16, in top-level template code
  {% assets "css_prep" %}
File "/opt/python/run/venv/lib/python2.7/site-packages/webassets/ext/jinja2.py", line 181, in _render_assets
  urls = bundle.urls(env=env)
File "/opt/python/run/venv/lib/python2.7/site-packages/webassets/bundle.py", line 685, in urls
  urls.extend(bundle._urls(env, extra_filters, *args, **kwargs))
File "/opt/python/run/venv/lib/python2.7/site-packages/webassets/bundle.py", line 647, in _urls
  *args, **kwargs)
File "/opt/python/run/venv/lib/python2.7/site-packages/webassets/bundle.py", line 504, in _build
  force, disable_cache=disable_cache, extra_filters=extra_filters)
File "/opt/python/run/venv/lib/python2.7/site-packages/webassets/bundle.py", line 390, in _merge_and_apply
  filters_to_pass_down, disable_cache=disable_cache)
File "/opt/python/run/venv/lib/python2.7/site-packages/webassets/bundle.py", line 429, in _merge_and_apply
  kwargs=item_data)
File "/opt/python/run/venv/lib/python2.7/site-packages/webassets/merge.py", line 272, in apply
  return self._wrap_cache(key, func)
File "/opt/python/run/venv/lib/python2.7/site-packages/webassets/merge.py", line 219, in _wrap_cache
  content = func().getvalue()
File "/opt/python/run/venv/lib/python2.7/site-packages/webassets/merge.py", line 252, in func
  getattr(filter, type)(data, out, **kwargs_final)
File "/opt/python/run/venv/lib/python2.7/site-packages/webassets/filter/sass.py", line 141, in input
  self._apply_sass(_in, out, os.path.dirname(source_path))
File "/opt/python/run/venv/lib/python2.7/site-packages/webassets/filter/sass.py", line 122, in _apply_sass
  shell=(os.name == 'nt'))
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
  errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1308, in _execute_child
  raise child_exception
OSError: [Errno 2] No such file or directory

现在,我正在使用pyscss,但它的实现存在缺陷,有时会生成不正确的CSS(例如,它会混淆SASS版本的Bootstrap)。

是否有强制我的Elastic Beanstalk应用程序在所有实例上安装SASS?

1 个答案:

答案 0 :(得分:0)

我能够通过sshing到实例并运行:

来安装sass
  

gem install sass

要在所有新实例上安装此项,请将其添加到.ebextensions目录中的配置文件

packages:
  rubygems:
    sass: ''

空引号指定安装最新版本。如果您需要特定版本,请在那里添加版本号。

更多信息在这里:

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-packages