grunt-compass
Advanced tools
Comparing version 0.3.2 to 0.3.3
{ | ||
"name": "grunt-compass", | ||
"description": "A custom grunt.js task that executes compass compile for you and prints the COMPASS output to grunt.log.write().", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"homepage": "https://github.com/kahlil/grunt-compass", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -12,3 +12,3 @@ # grunt-compass | ||
1. Install this grunt plugin next to your project's grunt.js gruntfile with: `npm install grunt-compass`. | ||
2. Call `grunt.loadNpmTasks('grunt-compass')` in your gruntfile. | ||
2. Call `grunt.loadNpmTasks( 'grunt-compass' )` in your gruntfile. | ||
3. Configure `grunt watch` to watch your scss files and call the task(s). | ||
@@ -19,4 +19,4 @@ e.g.: | ||
watch: { | ||
files: ['assets/scss/*.scss'], | ||
tasks: ['compass:dev', 'compass:prod'] | ||
files: [ 'assets/scss/*.scss' ], | ||
tasks: [ 'compass:dev', 'compass:prod' ] | ||
} | ||
@@ -34,27 +34,29 @@ ``` | ||
Also, you can use `src` to specify certain files you want to compile: | ||
5. Use `specify` to specify certain files you want to compile: | ||
A single file. | ||
A single file. | ||
```javascript | ||
src: 'assets/scss/base.scss' | ||
``` | ||
```javascript | ||
specify: 'assets/scss/base.scss' | ||
``` | ||
Use globbing to match files, like: | ||
Use globbing to match files, like: | ||
```javascript | ||
src: 'assets/scss/*.scss' // Match all scss files under `assets/scss` but not include files in subdirctory. | ||
src: 'assets/scss/**/*.scss' // Match all scss files under `assets/scss` include files in subdirctory. | ||
``` | ||
```javascript | ||
specify: 'assets/scss/*.scss' // Match all scss files under `assets/scss` but not include files in subdirctory. | ||
specify: 'assets/scss/**/*.scss' // Match all scss files under `assets/scss` include files in subdirctory. | ||
``` | ||
See [minimatch](https://github.com/isaacs/minimatch) for more globbing usage. | ||
See [minimatch](https://github.com/isaacs/minimatch) for more globbing usage. | ||
Note a SASS/SCSS file will be ignored if its filename begin with an underscore `_`. See [SASS-partials](http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#partials). | ||
Note a SASS/SCSS file will be ignored if its filename begin with an underscore `_`. And all files you specify **MUST** under directory the `src` specified. | ||
5. You can set your custom output style like this: | ||
See [SASS-partials](http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#partials). | ||
6. You can set your custom output style like this: | ||
```javascript | ||
outputstyle: 'compressed' | ||
``` | ||
6. You can disable line comments like this: | ||
7. You can disable line comments like this: | ||
@@ -64,3 +66,3 @@ ```javascript | ||
``` | ||
7. If you have multiple compass tasks and you want to force compass compilation you can do this: | ||
8. If you have multiple compass tasks and you want to force compass compilation you can do this: | ||
@@ -70,3 +72,3 @@ ```javascript | ||
``` | ||
8. You can require a given ruby library before running commands like this: | ||
9. You can require a given ruby library before running commands like this: | ||
@@ -77,3 +79,3 @@ ```javascript | ||
9. You can add the `--debug-info` option for use with [FireSass](https://addons.mozilla.org/en-US/firefox/addon/firesass-for-firebug/) like so: | ||
10. You can add the `--debug-info` option for use with [FireSass](https://addons.mozilla.org/en-US/firefox/addon/firesass-for-firebug/) like so: | ||
@@ -84,3 +86,3 @@ ```javascript | ||
10. You can set the relative assets to `true` and set an image path for the Compass spriting feature: | ||
11. You can set the relative assets to `true` and set an image path for the Compass spriting feature: | ||
@@ -92,3 +94,3 @@ ```javascript | ||
11. You can run compass with bundle exec if you need to as well: | ||
12. You can run compass with bundle exec if you need to as well: | ||
@@ -99,3 +101,3 @@ ```javascript | ||
12. If you have a Compass configuration file, you can use it instead of or in addition to the options in your gruntfile: | ||
13. If you have a Compass configuration file, you can use it instead of or in addition to the options in your gruntfile: | ||
@@ -108,3 +110,3 @@ ```javascript | ||
13. If you have a Compass configuration file, you set the environment variable for the config.rb file: | ||
14. If you have a Compass configuration file, you set the environment variable for the config.rb file: | ||
@@ -118,8 +120,7 @@ ```javascript | ||
```ruby | ||
output_style = (environment == :production) ? :compressed : :expanded | ||
output_style = ( environment == :production ) ? :compressed : :expanded | ||
``` | ||
15. You can add a custom `IMPORT_PATH` folder, which makes files under the path findable by Sass's `@import` directive: | ||
14. You can add a custom `IMPORT_PATH` folder, which makes files under the path findable by Sass's `@import` directive: | ||
```javascript | ||
@@ -129,12 +130,12 @@ importPath: '/path/to/importPath' | ||
15. `grunt compass-clean` | ||
16. `grunt compass-clean` | ||
Sometimes it can be faster to execute `compass clean` and recompile for production instead of doing `--force` compile. | ||
Now grunt-compass comes with a `grunt compass-clean` task that you can use when registering prod tasks in your gruntfile like: | ||
Sometimes it can be faster to execute `compass clean` and recompile for production instead of doing `--force` compile. | ||
Now grunt-compass comes with a `grunt compass-clean` task that you can use when registering prod tasks in your gruntfile like: | ||
```js | ||
grunt.registerTask('prod', ['compass-clean', 'compass:prod']); | ||
``` | ||
```js | ||
grunt.registerTask( 'prod', [ 'compass-clean', 'compass:prod' ] ); | ||
``` | ||
16. Run "grunt watch" and edit some SASS files :) | ||
17. Run "grunt watch" and edit some SASS files :) | ||
@@ -141,0 +142,0 @@ # An Example Setup |
@@ -1,2 +0,2 @@ | ||
var Fs = require( 'fs' ); | ||
var Fs = require( 'fs' ); | ||
var Path = require( 'path' ); | ||
@@ -9,29 +9,32 @@ | ||
var src, dest, specify, matchedFiles; | ||
// Tell grunt this task is asynchronous. | ||
var done = this.async(), | ||
exec = require('child_process').exec, | ||
command = "compass compile", | ||
src = undefined, | ||
dest = undefined, | ||
config = this.data.config, | ||
images = this.data.images, | ||
fonts = this.data.fonts, | ||
outputstyle = this.data.outputstyle, | ||
linecomments = this.data.linecomments, | ||
forcecompile = this.data.forcecompile, | ||
debugsass = this.data.debugsass, | ||
relativeassets = this.data.relativeassets, | ||
libRequire = this.data.require, | ||
bundleExec = this.data.bundleExec; | ||
environment = this.data.environment, | ||
importPath = this.data.importPath; | ||
var done = this.async(); | ||
var exec = require('child_process').exec; | ||
var command = "compass compile"; | ||
var config = this.data.config; | ||
var images = this.data.images; | ||
var fonts = this.data.fonts; | ||
var outputstyle = this.data.outputstyle; | ||
var linecomments = this.data.linecomments; | ||
var forcecompile = this.data.forcecompile; | ||
var debugsass = this.data.debugsass; | ||
var relativeassets = this.data.relativeassets; | ||
var libRequire = this.data.require; | ||
var bundleExec = this.data.bundleExec; | ||
var environment = this.data.environment; | ||
var importPath = this.data.importPath; | ||
if ( this.data.src !== undefined ) { | ||
src = grunt.template.process(this.data.src); | ||
src = grunt.template.process( this.data.src ); | ||
} | ||
if ( this.data.dest !== undefined ) { | ||
dest = grunt.template.process(this.data.dest); | ||
dest = grunt.template.process( this.data.dest ); | ||
} | ||
if( this.data.specify !== undefined ) { | ||
specify = grunt.template.process( this.data.specify ); | ||
} | ||
if ( bundleExec ) { | ||
@@ -42,32 +45,19 @@ command = 'bundle exec ' + command; | ||
if ( src !== undefined && dest !== undefined ) { | ||
command += ' --sass-dir="' + src + '" --css-dir="' + dest + '"'; | ||
// Get stats of `src`, `ENOENT` error will be throw out if src is not an regular path. | ||
try { | ||
var srcStats = Fs.statSync( Path.resolve( process.cwd(), src )); | ||
} | ||
catch(e){ | ||
srcStats = undefined; | ||
} | ||
// Specify sass files to be compiled in directory `src`. | ||
if ( specify !== undefined ) { | ||
// If `src` is a directory, use option `--sass-dir`. | ||
if( srcStats && srcStats.isDirectory() ){ | ||
command += ' --sass-dir="' + src + '" --css-dir="' + dest + '"'; | ||
} | ||
// Otherwise use `src` as the argument for command `compile`. | ||
else { | ||
var matchedFiles = grunt.file.expandFiles( src ); | ||
if( matchedFiles.length > 0 ){ | ||
matchedFiles = grunt.file.expandFiles( specify ); | ||
if ( matchedFiles.length > 0 ) { | ||
// Add all but filename begin with underscore after `compile` command. | ||
matchedFiles.forEach(function( file ){ | ||
if( Path.basename(file).charAt( 0 ) != '_' ){ | ||
matchedFiles.forEach( function( file ) { | ||
if ( Path.basename( file ).charAt( 0 ) != '_' ) { | ||
command += ' ' + file; | ||
} | ||
}); | ||
command += ' --css-dir="' + dest + '"'; | ||
} | ||
else { | ||
grunt.log.error( 'No file matched with: ' + src ); | ||
done(false); | ||
grunt.log.error( 'No file matched with: ' + specify ); | ||
done( false ); | ||
} | ||
@@ -129,12 +119,10 @@ } | ||
grunt.log.write( stdout ); | ||
/* grunt.log.error( stderr ); | ||
* compass sends falsy error message to stderr... real sass/compass errors come in through the "error" variable. | ||
*/ | ||
// compass sends falsy error message to stderr... real sass/compass errors come in through the "error" variable. | ||
if ( error !== null ) { | ||
grunt.log.error( error ); | ||
done(false); | ||
done( false ); | ||
} | ||
else { | ||
done(true); | ||
done( true ); | ||
} | ||
@@ -141,0 +129,0 @@ } |
209
14103
128