material icon indicating copy to clipboard operation
material copied to clipboard

Media query with \0 causing parsing issues with node-sass and LESS

Open jraadt opened this issue 10 years ago • 57 comments

Because of the https://github.com/angular/material/commit/f3761781f74065c3d6cba8029a3ba420aab957ff commit, which includes a \0 after the media definition, applications using LESS and importing the generated CSS file with the less option to have access to classes and such within LESS no longer work. LESS doesn't support the \0 media query hack. Import example:

@import (less) 'angular-material/angular-material.css';

When trying to compile LESS you get the following error:

media definitions require block statements after any features in file angular-material\angular-material.css line no. 654

jraadt avatar Dec 15 '15 04:12 jraadt

Also having this issue. Had to split up my vendor + app styling, but not ideal.

barryvdh avatar Dec 15 '15 09:12 barryvdh

I think I have a similar problem using SASS:

Error: Invalid CSS after "...a screen\\0  and": expected "{", was "-width: 599px) ..."
    on line 1286 of stdin
    >> @media screen\0  and (max-width: 599px) {
   -------^

larsRedia avatar Dec 15 '15 09:12 larsRedia

@jraadt I also ran into the same with less, and I see that you found the same feature/bug in the less repo as I did. https://github.com/less/less.js/issues/1538

Seems like this could be made to be supported with less anyway by a small modification to that media query?

enghen10 avatar Dec 15 '15 14:12 enghen10

Same issue using node-sass (which uses libsass under the hood).

kouak avatar Dec 15 '15 17:12 kouak

I can confirm the issue in node-sass as well. It's breaking everything since the angular-material.css module is not building when we deploy to our server.

johnsheldon avatar Dec 16 '15 18:12 johnsheldon

same problem, when i try deploy to heroku Related https://github.com/angular/material/issues/6360

idoo avatar Dec 17 '15 16:12 idoo

+1

Sayene avatar Dec 19 '15 10:12 Sayene

+1

stalinb87 avatar Dec 22 '15 17:12 stalinb87

+1

a-boertien avatar Dec 29 '15 23:12 a-boertien

+1

simonh1000 avatar Dec 30 '15 09:12 simonh1000

+1

jcmccormick avatar Jan 05 '16 09:01 jcmccormick

Same issue with angular-material 1.0.0 installed over bower. It (libsass?) chokes on the \0 IE hacks:

>> Invalid CSS after "...ia screen\\0 and": expected "{", was "-width:599px){...."
>>   Line 6  Column 25446  bower_components/angular-material/angular-material.min.css

alextreppass avatar Jan 10 '16 21:01 alextreppass

+1 angular-material 1.0.1 with node-sass ^3.4.1

ddjonline avatar Jan 12 '16 15:01 ddjonline

+1 me too with angular-material 1.0.1 and node-sass cli

breity avatar Jan 14 '16 23:01 breity

Was there a work around for this?

angular-material 1.0.1-master-d1b7f79

Sass::SyntaxError: Invalid CSS after "...a screen\0 and ": expected "{", was "(max-width: 599..."

lasernite avatar Jan 16 '16 21:01 lasernite

I, too, would love a work around for this.

Currently, I'm stuck using 0.9.8, which cuts out a hefty chunk of functionality.

Using Ruby on Rails with the sass-rails gem.

jcmccormick avatar Jan 17 '16 01:01 jcmccormick

+1 for me too

prijindal avatar Jan 17 '16 15:01 prijindal

I was having the same problem while using gulp

What i did was before feeding it into the sass compiler, I replaced all '\0' with a space ' '

  return gulp.src(assets.vendorCss.main)
    .pipe(replace('screen\\0','screen'))
    .pipe(concat(assets.vendorCss.output.filename))
    .pipe(sass({outputStyle: 'compressed'}))
    .pipe(gulp.dest(assets.vendorCss.output.path))

And now it works greatly Note: I am using gulp-sass for compiling, i am not sure how gulp-ruby-sass handles it but i think this workaround should work for them

prijindal avatar Jan 17 '16 15:01 prijindal

It was failing for me in rails using sass-rails. Sprockets doesn't make it easy to pipe it through a string replace function so... Changing line 666 of angular-material.scss from @media screen\0 { to @media screen {

was all that was required for me to get it to compile.

alanwilhelm avatar Jan 20 '16 18:01 alanwilhelm

@prijindal this way works for me! I am now with angular-marterial 1.0.1 and node-saas in my gulp building process.

Just to add a point: replace is not a default function in gulp so you have to install gulp-replace in advance.

kavare avatar Jan 22 '16 14:01 kavare