Mdb-ui-kit: Build error with node-sass v4.8.2

Created on 12 Mar 2018  ยท  20Comments  ยท  Source: mdbootstrap/mdb-ui-kit

Test Case

  • clone repository
  • execute yarn upgrade
  • run npm run build

Summary

{
  "status": 1,
  "file": "/tmp/bootstrap-material-design/scss/mixins/_forms.scss",
  "line": 155,
  "column": 3,
  "message": "Base-level rules cannot contain the parent-selector-referencing character '&'.\n\nBacktrace:\n\tscss/mixins/_forms.scss:155, in mixin `bmd-form-color`\n\tscss/_forms.scss:75",
  "formatted": "Error: Base-level rules cannot contain the parent-selector-referencing character '&'.\n\n       Backtrace:\n       \tscss/mixins/_forms.scss:155, in mixin `bmd-form-color`\n       \tscss/_forms.scss:75\n        on line 155 of scss/mixins/_forms.scss\n>>   &.is-focused {\n\n   --^\n"
}
Error: Base-level rules cannot contain the parent-selector-referencing character '&'.

       Backtrace:  
           scss/mixins/_forms.scss:155, in mixin `bmd-form-color`  
           scss/_forms.scss:75
        on line 155 of scss/mixins/_forms.scss
>>   &.is-focused {

   --^

The reason is found in:

Expected result

Successful build.

bug confirmed

Most helpful comment

@FezVrasta

I've fixed this issue compiling bmd on a Ruby project that uses Sass 3.5.2.

I've replaced the buggy & for this:
#{if(&, "&", "*")}

scss/mixins/_drawer.scss
screen shot 2018-09-04 at 11 47 43 am

scss/mixins/_form.scss
screen shot 2018-09-04 at 11 46 53 am

sass/sass#1873 helped me out.

Do you want a pull request with these changes? The focus styles looks ok on my end.
screen shot 2018-09-04 at 11 52 26 am

All 20 comments

Our build uses node-sass, what version are you using? Try 4.5.3 please

yarn.lock is currently using v4.7.2 of node-sass, which builds sucessfully. Current version of node-sass is v4.8.2 which is legid due package.json.
But build fails with node-sass v4.8.2.

If you include bootstrap-material-design scss code in other project and run yarn upgrade/npm update, you are getting this error.

Thanks, they introduced a breaking change in a minor version then... I'd open an issue on their repository to see if this is expected. If so, I guess we'll have to find some way to workaround the problem.

Ok looks like that code was never supposed to work.

https://github.com/sass/libsass/issues/2581

I can't find any way to rewrite that mixin to work with the new version requirements... Help is more than welcome.

I can confirm this error is correct.

The code is invalid and should never have worked. It worked due a bug that has since been fixed.

Please see this blog post for why this isn't a breaking a change.

You cannot use & outside of a selector. In this case

  • @include bmd-form-color is called outside of a selector
  • inside that mixin &.is-focus is called outside of a selector

This is a error because & is essentially undefined.

How can I tell Sass to consider & the :root scope of the DOM?

That's not how & works. & is always the parent selector.

To get to the root you can use @at-root. The following

@at-root (without: all) {
  .is-focused { ... }
}

is pretty much the same as

:root { 
  is-focused { .. } 
}

@FezVrasta

I've fixed this issue compiling bmd on a Ruby project that uses Sass 3.5.2.

I've replaced the buggy & for this:
#{if(&, "&", "*")}

scss/mixins/_drawer.scss
screen shot 2018-09-04 at 11 47 43 am

scss/mixins/_form.scss
screen shot 2018-09-04 at 11 46 53 am

sass/sass#1873 helped me out.

Do you want a pull request with these changes? The focus styles looks ok on my end.
screen shot 2018-09-04 at 11 52 26 am

I don't see this issue with latest node-sass v4.9.4. Per my understanding from above discussions / blog, it's not complaint with sass specifications. @xzyfer, can you please cross check?
For reference, dart-sass v1.14.3, shows this as non compliant.

I've run into the same error while updating my dependencies.
The solution of @jpaulomotta works also in my environment :)

Is there a planed version where the fix will be released?
@FezVrasta if you need help, I can try to make the fix and send you an pull-request?

Any updates on this issue?

Yea, sorry, a pull request to fix it would be great.

So will you fix this bug?

Similar bug in node_modules\bootstrap-material-design\scss\mixins\_forms.scss 153:3, can you fix this too?

      Top-level selectors may not contain the parent selector "&".
    โ•ท
153 โ”‚ โ”Œ   .is-focused,
154 โ”‚ โ”‚   // may or may not be a form-group or bmd-form-group
155 โ”‚ โ”‚   &.is-focused {
    โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€-^

This should be ok in the fix but it wasn't yet merged.

@FezVrasta any idea when you could check an merge?

This should be ok in the fix but it wasn't yet merged.

Yea, I'm sorry I was a little inattentive

Would be great if you could push this to npm, currently I can not build because of this:
grafik

@FezVrasta Can't install this hotfix. Please push a new version tag.


The only workaround at the moment is to install the package referencing the GitHub repository

```
npm i --save-dev bootstrap-material-design@master

Hey guys, I've encountered this issue, but it doesn't seems to be deployed in production. Last version is 4.1.2 and I still encounter this issue @FezVrasta

Push because as i encounter this issue also with sass 1.26.0 in _forms.scss as @Trojaner posted already.

Hi please push to npm as the fix is really needed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rh78 picture rh78  ยท  8Comments

rajavijayavendan picture rajavijayavendan  ยท  7Comments

thangchung picture thangchung  ยท  3Comments

hans-d picture hans-d  ยท  5Comments

ViRuSTriNiTy picture ViRuSTriNiTy  ยท  6Comments