Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sass failed when generate bundles from CLI #91

Open
Slach opened this issue Jun 13, 2015 · 2 comments
Open

sass failed when generate bundles from CLI #91

Slach opened this issue Jun 13, 2015 · 2 comments

Comments

@Slach
Copy link

Slach commented Jun 13, 2015

i have flask application with buildout in src folder

./bin/pip show flask | grep Version

Version: 0.10.1

./bin/pip show flask-assets | grep Version

Version: 0.10

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 */
        ],
    },
}

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',
    ),

})

src/spf/init.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

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 and have 0777 access right

but when i run
./bin/spf_dev assets -v build

i have error

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

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

but i don't understand
why sass don't use src/assets for resolve relative path in @import directive from stdin?

self.append_path('src/assets')

@miracle2k
Copy link
Owner

The comment you linked to shouldn't apply to your case, since you do not configure the sass filter as an "output filter".

I don't see anything obvious wrong.

Look here: https://github.com/miracle2k/webassets/blob/master/src/webassets/filter/sass.py#L163

At this point the working directory should be set to src/assets/scss/. I would then expect sass to find the include file in the same directory as the theme.scss file itself. Maybe by calling the command being executed at this point manually, you can figure out why not.

@Slach
Copy link
Author

Slach commented Jun 15, 2015

After rollback to old version 3.4.13 of sass , everything work fine...
see
sass/sass#1745

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants