我有使用buildout环境的烧瓶应用程序
./bin/pip show flask | grep Version
Version: 0.10.1
./bin/pip show flask-assets | grep Version
Version: 0.10
src 文件夹中的src / setup.py有以下字符串
setup(
name = 'spf',
install_requires = [
'flask',
'flask-assets',
],
entry_points = {
'console_scripts': [
'spf_dev = spf.manage:dev', /* see manage.py dev function */
],
},
}
生成的bin / spf_dev我有 src / spf / manage.py,代码如下
from flask.ext import assets
from . import env
def init (app):
manager = script.Manager(app)
manager.add_command(
'assets',
assets.ManageAssets(app.assets),
)
return manager
def dev ():
init(env.dev.app).run()
我使用的烧瓶环境初始化 SRC / SPF / ENV / dev.py
from spf import init
app = init({
'ASSETS_DIR': 'src/spf/static/assets',
'ASSETS_URL': '/assets/',
'SASS_STYLE': 'compressed',
'UGLIFYJS_EXTRA_ARGS': (
'-c',
'--screw-ie8',
),
})
我实现了返回wsgi app的init函数 SRC / SPF /的初始化的.py
import flask
from . import assets
def init (env_config=None):
app = flask.Flask(
'spf',
static_url_path='',
)
app.config.update(evn_config)
app.assets = assets.Assets(app)
return app
资产模块与Bundle注册 SRC / SPF / assets.py
from flask.ext.assets import (
Environment,
Bundle,
)
class Assets (Environment):
def __init__ (self, app):
super(Assets, self).__init__(app)
if 'ASSETS_DIR' in app.config:
self.directory = app.config['ASSETS_DIR']
if 'ASSETS_URL' in app.config:
self.url = app.config['ASSETS_URL']
if 'SASS_STYLE' in app.config:
self.config['sass_style'] = app.config['SASS_STYLE']
if 'UGLIFYJS_EXTRA_ARGS' in app.config:
self.config['UGLIFYJS_EXTRA_ARGS'] = \
app.config['UGLIFYJS_EXTRA_ARGS']
self.register('theme.css', Bundle(
'scss/theme.scss',
filters='scss',
output='theme.css',
))
self.append_path('src/assets')
src / assets / scss / theme.scss
@import 'btn-o';
但是当我跑步时
buildout -c src/buildout.cfg
./bin/spf_dev assets -v build
我有错误
Building bundle: theme.css
Failed, error was: sass: subprocess had error: stderr=Error: File to import not found or unreadable: ./btn-o. on line 1 of standard input
Use --trace for backtrace. , stdout=, returncode=65
我已阅读https://github.com/miracle2k/webassets/blob/master/src/webassets/filter/sass.py#L36
但我不明白;-( 在使用self.append_path(' src / assets')之后,为什么sass不使用src / assets来解决来自stdin的@import指令中的相对路径?
答案 0 :(得分:3)
您需要为sass过滤器添加一个加载路径,以使其适用于3.4.14
SELECT userID INTO #table
FROM users
WHERE LastName = CASE
WHEN @LastName = 'All' THEN LastName
ELSE @LastName END
然后,当您注册捆绑包时:
sass = get_filter('scss')
sass.load_paths = [os.path.join(app.static_folder, 'scss')]
答案 1 :(得分:2)
问题出在SASS 3.4.14
中解决方法是
sudo gem uninstall sass
sudo gem install sass -v 3.4.13