Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

SCSS not working #33

Closed
burningTyger opened this issue Mar 20, 2018 · 5 comments
Closed

SCSS not working #33

burningTyger opened this issue Mar 20, 2018 · 5 comments
Labels

Comments

@burningTyger
Copy link
Contributor

burningTyger commented Mar 20, 2018

I have added the scss loader:

    httpVueLoader.langProcessor.scss = function (scssText) {
        let css = ''
        sass.compile(scssText, function (result) {
            css = result.text
        })
        return css
    }

and in my template I have:

<style scoped lang='scss' src='page.scss'></style>

I know that the langProcessor works because if I add a console.log(css) I get valid css.
Since I have working processors for pug and es6 via babel I don't think my setup is broken.

If I just use plain css as in:

<style scoped>
  .main { color: red}
</style>

it also works.

I couldn't import via @import inside my style tags because then the page.scss file was never found so I gave up on that. Still, I can't see why this is not working.

@FranckFreiburger
Copy link
Owner

Since sass.compile is asynchronous, you should return a promise:

    httpVueLoader.langProcessor.scss = function (scssText) {
        return new Promise(function(resolve, reject) {
            sass.compile(scssText, function (result) {
                if ( result.status === 0 )
                    resolve(result.text)
                else
                    reject(result)
            });
        });
    }

(untested)

@burningTyger
Copy link
Contributor Author

Yes, that's it. Maybe add that to the docs? Works without modifications.

@FranckFreiburger
Copy link
Owner

FranckFreiburger commented Mar 21, 2018 via email

@Arturokin12
Copy link

where do you get that sass.compile function? still fighting with that

@gaby64
Copy link

gaby64 commented Dec 17, 2019

where do you get that sass.compile function? still fighting with that

https://github.com/medialize/sass.js/

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

No branches or pull requests

4 participants