python - flask-assets - sass don't resolve relative path in @import scss directive -


i have flask application buildout environment

./bin/pip show flask | grep version version: 0.10.1 ./bin/pip show flask-assets | grep version version: 0.10 

in src folder src/setup.py have following strings

setup(     name = 'spf',     install_requires = [         'flask',         'flask-assets',     ],     entry_points = {         'console_scripts': [             'spf_dev = spf.manage:dev', /* see manage.py dev function */         ],     }, } 

for generated bin/spf_dev have src/spf/manage.py following code

from flask.ext import assets . 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() 

for flask environment initialization use 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',     ),  }) 

and implement init function return wsgi app in src/spf/init.py

import flask . 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 

assets module bundle registration 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'; 

src/assets/scss/_btn-o.scss exists, not empty , have 0777 access right

but when run

buildout -c src/buildout.cfg ./bin/spf_dev assets -v build 

i have error

building bundle: theme.css failed, error was: sass: subprocess had error: stderr=error: file import not found or unreadable: ./btn-o. on line 1 of standard input   use --trace backtrace. , stdout=, returncode=65 

i have read https://github.com/miracle2k/webassets/blob/master/src/webassets/filter/sass.py#l36

but don't understand ;-( why sass don't use src/assets resolve relative path in @import directive stdin after used self.append_path('src/assets') ?

you need add load path sass filter work 3.4.14

sass = get_filter('scss') sass.load_paths = [os.path.join(app.static_folder, 'scss')] 

then, when register bundle:

self.register('theme.css', bundle(     'scss/theme.scss',     filters=(sass,),     output='theme.css', )) 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -