gruntjs / grunt-contrib-sass

Compile Sass to CSS.
http://gruntjs.com/
MIT License
848 stars 141 forks source link

Cannot compile a partial #180

Closed glebm closed 9 years ago

glebm commented 9 years ago

I am developing a Sass library that consists only of partials. However, it seems impossible to use grunt-contrib-sass to compile non-partials.

dist: {
  files: {
    'dist/css/library.css': 'scss/_library.scss' // <- not compiled
  }
}

The reasons I want only partials in the library:

  1. Sass --watch outputs all non-prefixed files as separate CSS files. E.g. if a user copies my library directly into the project, then imports it into their scss/main.scss, and runs sass --watch:
$ sass --watch scss:public  
      write public/main.css
      write public/library.css
  1. Compass copies all non-partials in the libraries into the project when the library is added:
$ compass compile
 modified config.rb
        ...
    write stylesheets/screen.css
directory stylesheets/library
    write stylesheets/library/library.css

Sister ticket: https://github.com/sindresorhus/grunt-sass/issues/176

tbremer commented 9 years ago

SASS inherently does not compile partials (assuming you use the _partial.s(ac)ss convention).

This library (obviously) follows that same convention. You only need to send this module your non partial files, and your output files.

Sent from my iPhone

On Jan 18, 2015, at 8:07 PM, Gleb Mazovetskiy notifications@github.com wrote:

I am developing a Sass library that consists only of partials. However, it seems impossible to use grunt-contrib-sass to compile non-partials.

The reasons I want only partials in the library:

Sass --watch outputs all non-prefixed files as separate CSS files. E.g. if a user copies my library directly into the project, then imports it into their scss/main.scss, and runs sass --watch: $ sass --watch scss:public
write public/main.css write public/library.css Compass copies all non-partials in the libraries into the project when the library is added: $ compass compile modified config.rb ... write stylesheets/screen.css directory stylesheets/library write stylesheets/library/library.css — Reply to this email directly or view it on GitHub.

glebm commented 9 years ago

SASS inherently does not compile partials (assuming you use the _partial.s(ac)ss convention).

Sass can compile partials:

$ sass tmp/_test.sass # works
sindresorhus commented 9 years ago

The problem is that this task don't know whether a glob or specific file where used as grunt does the globbing and just passes down a list of files. Just import your partials into a normal Sass file and compile that instead.

glebm commented 9 years ago

This would require a new option to override the behaviour (e.g. compilePartials: true). I'll see if I can PR this soon.

tbremer commented 9 years ago

Sass will compile anything you pass it, but the idea of a partial is that you import it into another file.

If you were to use --update or --watch and pass your input and output directory then you'd see That Sass does not compile partials, it compiles the files that import said partials.