leafo / scssphp

SCSS compiler written in PHP
MIT License
1.34k stars 214 forks source link

Loosen up syntax requirements for @import #391

Closed greg-1-anderson closed 8 years ago

greg-1-anderson commented 8 years ago

According to the official SASS Reference manual, the syntax for @import is:

@import "foo.scss";

However, some SASS compilers accept:

@import "foo.scss"

n.b. missing terminating semicolon.

Although this is technically a syntax error, since it is not enforced by some compilers, it creeps in to some project's sass files. It would be helpful is the scssphp parser could accept import statements without this trailing semicolon, so that scssphp can be used as a drop-in replacement for projects formerly using a Ruby-based compiler.

robocoder commented 8 years ago

scssphp already supports this in some cases. If you have an @import example that compiles in ruby scss but not scssphp, then please post and re-open.

greg-1-anderson commented 8 years ago

I cannot re-open, but the Drupal theme FortyTwo does not compile in scssphp using version 0.6.1. I made a fortytwo subtheme, but you can reproduce just by compiling directly from the STARTERKIT directory:

$ pscss themes/fortytwo/STARTERKIT/static/sass/main.sass 
PHP Fatal error:  Uncaught exception 'Leafo\ScssPhp\Exception\ParserException' with message 'parse error: failed at `@import "lib/_basicimports"` main.sass on line 2' in .../vendor/leafo/scssphp/src/Parser.php:120

After fixing the @import directives, by adding a ; to the end of each import line in main.sass:

$ pscss themes/fortytwo/STARTERKIT/static/sass/main.sass 
PHP Fatal error:  Uncaught exception 'Leafo\ScssPhp\Exception\ParserException' with message 'parse error: failed at `%clearfix` lib/_mixins.sass on line 1' in .../vendor/leafo/scssphp/src/Parser.php:120

At this point my goal is simply to make an example / proof-of-concept, so if you happen to know a Drupal theme that compiles with the latest scssphp, please point me at it.

robocoder commented 8 years ago

Sorry, I'm considering this as a wontfix. ruby scss 3.4.20 errored out on FortyTwo's main.sass:

Error: Invalid CSS after "...tings from them": expected selector or at-rule, was "@import "site/_..."
        on line 6 of main.sass
  Use --trace for backtrace.
greg-1-anderson commented 8 years ago

Okay, no problem. Does leave me wondering what they are using to compile their SASS, but I agree this is not your problem.

robocoder commented 8 years ago

Sorry, I took another look. FortyTwo uses the sass syntax. scssphp only supports the scss syntax.

greg-1-anderson commented 8 years ago

Sorry for the confusion; I thought .scss == sass css. Didn't realize there were two syntax sets here.