【问题标题】:Use webassets scss filter on AWS Elastic Beanstalk在 AWS Elastic Beanstalk 上使用 webassets scss 过滤器
【发布时间】:2014-12-26 15:15:54
【问题描述】:

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 的方法?

【问题讨论】:

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


    【解决方案1】:

    我能够通过 ssh 进入实例并运行来安装 sass:

    gem 安装 sass

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

    packages:
      rubygems:
        sass: ''
    

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

    更多信息在这里:

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

    【讨论】:

    • 这不是一个完整的解决方案,因为 Elastic Beanstalk 会在没有警告的情况下自动终止并创建新实例。
    • 我打算尝试将命令添加到 .ebextensions 配置文件中。我会用结果更新我的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-28
    • 2020-08-24
    • 2017-09-20
    • 2015-09-26
    • 2014-09-22
    • 2017-03-26
    • 2015-06-11
    相关资源
    最近更新 更多