Code Monkey home page Code Monkey logo

grunt-contrib-compass's Introduction

grunt-contrib-compass v1.1.1 Build Status: Linux Build Status: Windows

Compile Sass to CSS using Compass

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-contrib-compass --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-contrib-compass');

Compass task

Run this task with the grunt compass command.

Compass is an open-source authoring framework for the Sass css preprocessor. It helps you build stylesheets faster with a huge library of Sass mixins and functions, advanced tools for spriting, and workflow improvements including file based Sass configuration and a simple pattern for building and using Compass extensions.

This task requires you to have Ruby, Sass, and Compass >=1.0.1 installed. If you're on OS X or Linux you probably already have Ruby installed; test with ruby -v in your terminal. When you've confirmed you have Ruby installed, run gem update --system && gem install compass to install Compass and Sass.

Compass operates on a folder level. Because of this you don't specify any src/dest, but instead define the sassDir and cssDir options.

Options

Compass doesn't expose all of its options through the CLI, which this task makes use of. If you need an option not mentioned below you can either specify a path to a config.rb file in the config option or embed it directly into the raw option. Options defined in your Gruntfile will override those specified in your config.rb or raw property. config and raw are mutually exclusive.

sourcemap

Type: Boolean
Default: false

Generate Source Maps.

config

Type: String
Default: same path as your Gruntfile

Specify the location of the Compass configuration file explicitly.

raw

Type: String

String form of the Compass configuration file.

basePath

Type: String

The path Compass will run from. Defaults to the same path as your Gruntfile.

banner

Type: String

Prepend the specified string to the output file. Useful for licensing information. Note: This only works in combination with the specify option and can conflict with sourcemap generation.

app

Type: String
Default: stand_alone

Tell compass what kind of application it is integrating with. Can be stand_alone or rails.

sassDir

Type: String

The source directory where you keep your Sass stylesheets.

cssDir

Type: String

The target directory where you keep your CSS stylesheets.

specify

Type: String|Array

Lets you specify which files you want to compile. Useful if you don't want to compile the whole folder. Globbing supported. Ignores filenames starting with underscore. Paths are relative to the Gruntfile.

imagesDir

Type: String

The directory where you keep your images.

javascriptsDir

Type: String

The directory where you keep your JavaScript files.

fontsDir

Type: String

The directory where you keep your fonts.

environment

Type: String
Default: development

Use sensible defaults for your current environment. Can be: development or production

outputStyle

Type: String

CSS output mode. Can be: nested, expanded, compact, compressed.

relativeAssets

Type: Boolean

Make Compass asset helpers generate relative urls to assets.

noLineComments

Type: Boolean

Disable line comments.

httpPath

Type: String
Default: /

The path to the project when running within the web server.

cssPath

Type: String

The directory where the css stylesheets are kept. It is relative to the projectPath. Defaults to "stylesheets".

httpStylesheetsPath

Type: String
Default: httpPath + '/' + cssDir

The full http path to stylesheets on the web server.

sassPath

Type: String
Default: sass

The directory where the sass stylesheets are kept. It is relative to the projectPath.

imagesPath

Type: String
Default: images

The directory where the images are kept. It is relative to the projectPath.

httpImagesPath

Type: String
Default: httpPath + '/' + imagesDir

The full http path to images on the web server.

generatedImagesDir

Type: String
Default: value of imagesDir

The directory where generated images are kept. It is relative to the projectPath.

generatedImagesPath

Type: String
Default: value of projectPath/generatedImagesDir

The full path to where generated images are kept.

httpGeneratedImagesPath

Type: String
Default: httpPath + '/' + generatedImagesDir

The full http path to generated images on the web server.

spriteLoadPath

Type: String|Array
Default: value of imagesPath

Add additional locations to look for sprites. The imagesPath is always the last entry in this list.

javascriptsPath

Type: String
Default: projectPath/javascriptsDir

The full path to where javascripts are kept.

httpJavascriptsPath

Type: String
Default: httpPath + '/' + javascriptsDir

The full http path to javascripts on the web server.

fontsPath

Type: String
Default: projectPath/fontsDir

The full path to where font files are kept.

httpFontsPath

Type: String

The full http path to font files on the web server.

httpFontsDir

Type: String

The relative http path to font files on the web server.

extensionsPath

Type: String
Default: project_root/extensions

The full http path to the ad-hoc extensions folder on the web server. This is used to access compass plugins that have been installed directly to the project (e.g. through Bower) instead of globally as gems. Only Compass >=0.12.2

extensionsDir

Type: String

The relative http path to the ad-hoc extensions folder on the web server. Only Compass >=0.12.2

assetCacheBuster

Type: Boolean
Default: true

If set to false, this disables the default asset cache buster.

cacheDir

Type: String
Default: .sass-cache

The relative path to the folder where the sass cache files are generated.

require

Type: String|Array

Require the given Ruby library before running commands. This is used to access Compass plugins without having a project configuration file.

load

Type: String|Array

Load the framework or extensions found in the specified directory.

loadAll

Type: String|Array

Load all the frameworks or extensions found in the specified directory.

importPath

Type: String|Array

Makes files under the specified folder findable by Sass's @import directive.

debugInfo

Type: Boolean

Causes the line number and file where a selector is defined to be emitted into the compiled CSS in a format that can be understood by the browser. Automatically disabled when using outputStyle: 'compressed'.

quiet

Type: Boolean

Quiet mode.

trace

Type: Boolean

Show a full stacktrace on error.

force

Type: Boolean

Allows Compass to overwrite existing files.

boring

Type: Boolean

Turn off colorized output.

bundleExec

Type: Boolean

Run compass compile with bundle exec: bundle exec compass compile.

clean

Type: Boolean

Remove generated files and the sass cache. Runs compass clean instead of compass compile.

watch

Type: Boolean

Runs compass watch instead of compass compile. This will use Compass' native watch command to listen for changes to Sass files and recompile your CSS on changes. While much faster than running compass compile each time you want to compile your Sass, Compass becomes a blocking task. This means that if you would like to use it in conjunction with another blocking task, such as watch, you will need to use it in conjunction with a paralleling task such as grunt-concurrent.

Usage Examples

Example config

grunt.initConfig({
  compass: {                  // Task
    dist: {                   // Target
      options: {              // Target options
        sassDir: 'sass',
        cssDir: 'css',
        environment: 'production'
      }
    },
    dev: {                    // Another target
      options: {
        sassDir: 'sass',
        cssDir: 'css'
      }
    }
  }
});

grunt.loadNpmTasks('grunt-contrib-compass');

grunt.registerTask('default', ['jshint', 'compass']);

Example usage

Use external config file
grunt.initConfig({
  compass: {
    dist: {
      options: {
        config: 'config/config.rb'
      }
    }
  }
});
Override setting in external config file
grunt.initConfig({
  compass: {
    dist: {
      options: {
        config: 'config/config.rb',  // css_dir = 'dev/css'
        cssDir: 'dist/css'
      }
    }
  }
});
Use raw option
grunt.initConfig({
  compass: {
    dist: {
      options: {
        sassDir: 'sass',
        cssDir: 'css',
        raw: 'preferred_syntax = :sass\n' // Use `raw` since it's not directly available
      }
    }
  }
});

Release History

  • 2016-03-04   v1.1.1   Pass only compass package name, not full path.
  • 2016-02-15   v1.1.0   Use which to find compass binary cross platform. Update async and tmp dependencies.
  • 2015-09-29   v1.0.4   Use the compass flag for the httpPath option. Use single-quotes in the config.rb generated file.
  • 2015-04-02   v1.0.3   Add --config path before -- option/argument separator.
  • 2015-03-31   v1.0.2   Improve POSIX compliance.
  • 2014-09-08   v1.0.1   Use compass long flag for importPath.
  • 2014-09-05   v1.0.0   Fix bundleExec option on Windows.
  • 2014-07-31   v0.9.1   Fix npm peerDependency warnings.
  • 2014-06-24   v0.9.0   Add Compass version check to ensure only a supported version is used.
  • 2014-05-16   v0.8.0   Add spriteLoadPath option.
  • 2014-02-09   v0.7.2   Improve compatibility with Compass 0.13.
  • 2014-01-26   v0.7.1   Fix assetCacheBuster option.
  • 2013-12-07   v0.7.0   Add cacheDir option.
  • 2013-10-04   v0.6.0   Add watch option. Fix Compass errors not propagating.
  • 2013-08-8   v0.5.0   Add assetCacheBuster option.
  • 2013-07-28   v0.4.1   Fix banner option with .css.scss files.
  • 2013-07-19   v0.4.0   Add banner option. Show compilation time.
  • 2013-06-24   v0.3.0   Add extensionDir and extensionPath options. Requires Compass >=0.12.2.
  • 2013-04-11   v0.2.0   Add clean option. Expose raw options as Grunt options. Fix detection of Nothing to compile situation.
  • 2013-02-27   v0.1.3   Fixes bundleExec.
  • 2013-02-17   v0.1.2   Ensure Gruntfile.js is included on npm.
  • 2013-02-15   v0.1.1   First official release for Grunt 0.4.0.
  • 2013-02-05   v0.1.1rc8   Added new options: basePath, specify, debugInfo.
  • 2013-01-25   v0.1.1rc7   Updating grunt/gruntplugin dependencies to rc7. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.
  • 2013-01-10   v0.1.1rc5   Updating to work with Grunt v0.4.0rc5.
  • 2012-10-22   v0.1.0   Initial release

Task submitted by Sindre Sorhus

This file was generated on Wed Apr 06 2016 15:17:42.

grunt-contrib-compass's People

Contributors

aurelioderosa avatar badsyntax avatar carneiror avatar davidkaneda avatar fhemberger avatar jefflembeck avatar koenpunt avatar malys avatar mansona avatar maxcnunes avatar nschonni avatar passy avatar phadej avatar pixelime avatar radkodinev avatar robwierzbowski avatar rtgibbons avatar shairez avatar shama avatar sindresorhus avatar snugug avatar tedyoung avatar tudorcampean avatar vladikoff avatar xhmikosr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-contrib-compass's Issues

svn hook

when use grunt compass,compass is asynchronous,so the hook exit before compass complete

Malformed output appears when running task

I'm seeing the following upon running any of my grunt-contrib-compass tasks:
screen shot 2013-07-23 at 1 11 37 am

Note that they succeed, but the output is malformed.

For reference:

$ node -v
v0.11.5-pre
$ grunt --version
grunt-cli v0.1.9
grunt v0.4.1
$ npm view grunt-contrib-compass version
npm http GET https://registry.npmjs.org/grunt-contrib-compass
npm http 200 https://registry.npmjs.org/grunt-contrib-compass
0.4.0
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 11.04
Release:    11.04
Codename:   natty

My tasks:

        compass: {
            # Generates all css
            dist: {
                options: {
                    sassDir: 'webroot/sass',
                    cssDir: 'webroot/css',
                }
            },
            # Removes all generated CSS
            clean: {
                options: {
                    sassDir: 'webroot/sass',
                    cssDir: 'webroot/css',
                    clean: true
                }
            }
        },

Globbing patterns for sub-projects

I have several sub-projects that I want to run against a single Gruntfile, as they all need the same tasks running against them. For example, I need to compile the Sass using Compass in each sub-project.

I have tried globbing patterns:

compass: {
  options: {
    sassDir: './bundles/*/public/styles',
    cssDir: './bundles/*/temp/styles'
  }
}

But I get the following error:

Running "compass" (compass) task
Errno::ENOENT on line 441 of /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/pathname.rb: No such file or directory - /Users/Oliver/Development/Personal/Reader/bundles/*
Run with --trace to see the full backtrace

Suggesting I cannot use globbing patterns in this way with grunt-contrib-compass.

Watch not breaking on error?

It would be awesome if this plugin had the ability to show the error into console but not break the watch that is running. Having to constantly restart the grunt watch is a pain. grunt-contrib-less does this and it would be great to see it here too.

Changes from the future

The current release notes include a change dated 2014-04-11 -- about 11 months in the future.

I'll bet that was supposed to be 2013

The task breaks when have Sass errors

Hi @sindresorhus I'm using generator-webapp, and I want to know if this is a normal behaviour or a bug:

Using ruby the Compass don't stop the "compass watch" process, just put the error info in my compiled CSS.

So, the best behaviour is don't stop the grunt server task, right?

compass-abort

Overriding config.rb settings not working

I have the following Compass task:

compass: {
      options: {
        config: 'config.rb'
        // bundleExec: true
      },
      dev: {
        options: {
          imagesDir: 'images'
        }
      },
      dist: {
        options: {
          imagesDir: 'images-min'
        }
      }
    }

I've also got a registered task as follows:

grunt.registerTask('build', ['compass:dist']);

When I run Grunt Build, the file is unchanged and the new images directory is not used. Thoughts as to why? I'm running Grunt 0.4.0, Grunt Contrib Watch 0.4.0, and GC Compass 0.2.0.

Document differences between grunt-contrib-compass and grunt-contrib-sass

For example, please answer the following questions:

  • Why would I use grunt-contrib-compass instead of grunt-contrib-sass?
  • Are the same people working on both projects? Aren't you doubling the work to implement the same thing?

The answer to these questions is probably obvious to you, but at first glance it's confusing to me (at least).

How to respond to compass event

I'm trying to respond to compass task event

    grunt.event.on('compass', function(action, filepath) {
        grunt.log.write('compass executed');
    });

Compass task is being executed however, event is never fired.

Include banner option?

I'm currently using grunt-css to add a banner to my compiled stylesheet but since compass already provides concat and min functionalities it just feels like an overkill.

Is it possible to add this option? As far as I can tell there's no way to preserve part of the comments right now (you can either toggle them all on or off with noLineComments) not event using special comments like /*! ... */

Sprite image reference doesn`t work well, and Yeoman Grunt missing options

Yo.

I got a simple spriteSet in my webapp:

@import "icons/*.png";
@include all-icons-sprites;

Grunt or Compass generating the sprited image without any problems, inside my images folder, that was configured inside my yeoman project (more specifically- YO. The new one)

Now the image been generated well, and placed in the right location, but the reference to it inside my css output file is wrong.

More than that. I saw the options like httpGeneratedImagesPath, but these don`t seems to appear inside the gruntjsFile, inside my Yeoman project, and if I try to embed them, compass crush and no css get generated.

link for a discussion: yeoman/yeoman#596

Anyone encountered this problem before?
Thank you.

Expose more options

There are several options that are only available via the raw option, but aren't that unusual to be used, like the ones I described in my gist on how to use compass sprites.

Do you think it would make sense to automatically handle the options not available as command line flags as "raw" options, so you could specify them {httpImagesPath: "/images/"} as opposed to {raw: 'http_images_path = "/images/"\n'}? This would, however, require a fixed list of options that should be handled this way.

invalid option: --http-path

I just tried to set the option 'httpPath', but when I run

grunt compass:test

it returns

Running "compass:test" (compass) task
Error: invalid option: --http-path

When I run compass-v it shows a few valid options (e.g. --force and sass-dir), but not -http-path).

PS: I'm using Compass 0.12.2.

direct mapping Sass file(s) to css file

Is it possible to create a task that takes an array of srcFiles and specifies the exact output file, as in most other grunt plugins?

The compass model seems to be designed to take in a directory of sass files and output to another directory for css files. I am building a reusable module framework using grunt for the gluing. What I want to do is create a task that specifies several sass files, spread over many different directories, and have it compile and minify into a single css file i can specify.

debugsass option

The grunt-compass module has an option called debugsass which enables the --debug-info option. Is there an option for this in this task, or do you have to specify it in the config file?

raw config format

It might be nice from a readability standpoint if this was an array that got joined with newlines. Thoughts?

Compress option issue

Hi, the outputStyle: 'compressed' option passes an invalid argument to the compass compiler:

"Error: invalid option: --src"

grunt test aborted Warning: You need to have Ruby and Compass installed...

mbp:angular-seed brent$ grunt test
Running "clean:server" (clean) task

Running "concurrent:test" (concurrent) task
Warning: Running "compass:dist" (compass) task
Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Use --force to continue.

Aborted due to warnings. Use --force to continue.
    Aborted due to warnings.

mbp:angular-seed brent$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

mbp:angular-seed brent$ echo $PATH
/opt/local/bin:/opt/local/sbin:/Users/brent/.npm/grunt-contrib-compass/0.3.0/package/tasks:/Users/brent/.npm/grunt-contrib-compass/0.3.0/package/tasks/lib:/Users/brent/Sites/angular-seed/node_modules/grunt-contrib-compass/tasks:/Users/brent/Sites/angular-seed/node_modules/grunt-contrib-compass/tasks/lib:/opt/local/bin:/opt/local/sbin:/Users/brent/.npm/grunt-contrib-compass/0.3.0/package/tasks:/Users/brent/.npm/grunt-contrib-compass/0.3.0/package/tasks/lib:/opt/local/bin:/opt/local/sbin:/Users/brent/Sites/angular-seed/grunt-contrib-compass/tasks:/Users/brent/Sites/angular-seed/node_modules/grunt-contrib-compass/tasks:/usr/local/sbin:/usr/local/bin:/Library/PostgreSQL/9.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

mbp:angular-seed brent$ locate compass.js

/Users/brent/.npm/grunt-contrib-compass/0.3.0/package/tasks/compass.js
/Users/brent/.npm/grunt-contrib-compass/0.3.0/package/tasks/lib/compass.js
/Users/brent/Sites/angular-seed/node_modules/grunt-contrib-compass/tasks/compass.js
/Users/brent/Sites/angular-seed/node_modules/grunt-contrib-compass/tasks/lib/compass.js

I did:
npm cache clean
npm install grunt-contrib-compass --save-dev

Error: invalid option: --relativeassets

I'm getting this error as a result of using the plugin:


Error: invalid option: --relativeassets

Seems Compass is expecting --relative-assets parameter instead.

grunt --version:

grunt-cli v0.1.6
grunt v0.4.0
grunt-contrib-compass v0.1.2

compass --version:

Compass 0.12.2 (Alnilam)

Compass from RVM gemset

Do you know of a way to convince Grunt to use the binaries from an RVM gemset instead of system Ruby binaries?

I'm attempting to use my Gemfile/gemset to manage Compass-related dependencies, but my Grunt task is consistently invoking the compass installed with the system Ruby. (From my login shell, all works as expected.)

Thanks!

Source map support does not work in chrome

I built my sass files with debug flags (debugInfo: true), The output as follows

@media -sass-debug-info{filename{font-family:file\:\/\/\/Users\/maasaki\/development\/myproject\/app\/styles\/public\.scss}line{font-family:\0000387}}
.masthead .lead {
  color: #747c81;
}

Even after i enabled all Sass support flags in Chrome, it does not show scss files (only showing as usual css files). whats wrong with sass output?

Update for compatibility with grunt 0.4.0rc5

I need someone to help update this plugin to work with grunt 0.4.0rc5.

I had to revert the whole file src-dest mappings implicit iteration abstraction per gruntjs/grunt#606, and once again, multi tasks have to iterate over this.files manually. In addition, there's a new this.filesSrc array that contains a reduced, uniqued set of all matched src files in case the task is read-only and only cares about source files.

See:

Notes:

  • A user may specify a new option nonull in addition to src to tell grunt to keep patterns or filepaths that don't actually match files. Because of this, the task shouldn't explode if a nonexistent src filepath is encountered. I handle this in the grunt-contrib-concat by warning if not grunt.file.exists but not failing the task.

Guidelines for updating / publishing this plugin:

  • Change this project's version number to one ending in "rc5" so that it's clearer that it works with grunt 0.4.0rc5. If the existing version number doesn't end in an "a" or "rc" increment the patch version. Eg, jshint went from 0.1.0 -> 0.1.1rc5
  • Ensure grunt 0.4.0rc5-compatible plugins are specified in package.json devDependencies like this (grunt-contrib-internal can be "*")
  • Update the CHANGELOG like this
  • Regenerate the README.md file via grunt.
  • Delete node_modules, run npm cache clean and re-run npm install to test.
  • Publish to npm using --tag=master (not latest)

Clean option

I am moving my workflow away from running compass by itself with a few other tools into a proper Grunt "all-in-one" work flow.

I would like to define a clean task that will run clean on a few other things and also run clean in compass.

Could you add a option called clean and when that is set to true, it runs compass clean?

Warning: You need to have Ruby and Compass installed and in your system path for this task to work

I am a complete noob when working with ruby and compass so please forgive me. I am trying to use grunt. I am trying to use Yeoman and I have been getting everything setup. Upon trying to run the server I get the error -

"Warning: Running "compass:dist" (compass) task
Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Use --force to continue."

Then it is forced to quit. I have googled and tried reading documentation and haven't found a clear answer and solution. I found this issue - #61 but it didnt help me.

What am I doing wrong?

I am following this current tutorial - http://net.tutsplus.com/tutorials/javascript-ajax/building-apps-with-the-yeoman-workflow/

I apologize for my ignorance.

Is this available on npm?

Just tried npm install grunt-contrib-compass and got npm ERR! 404 grunt-contrib-compass is not in the npm registry

Creating two tasks at once not working like in v3

Hi! I am not able to make this basic function work on grunt 4 (no problem w/ grunt 3):

 compass: {
    dev: {
        sassDir: 'assets/sass',
        cssDir: 'assets/css-dev',
        outputStyle: 'nested',
        noLineComments: false
    },
    prod: {
        sassDir: 'assets/sass',
        cssDir: 'assets/css',
        outputStyle: 'compressed',
        noLineComments: true
    }
}

On grunt watch I use both, dev and prod to render both files, at least that is how it worked until grunt v3. Now I added the new syntax and it doesn’t work. All I get is Nothing to compile. If you're trying to start a new project, you have left off the directory argument. Run "compass -h" to get help.

If I add a config.rb file to my project grunt-contrib-compass uses the config.rb file exclusively. So both tasks do the same. The following doesn’t work also:

compass: {
    dev: {
        config: 'config.dev.rb'
    },
    prod: {
        config: 'config.prod.rb'
    }
}

trace option isn't giving a stack trace on watch

Doing a grunt watch, with trace:true, isn't showing the Compass stack trace.

Running "watch" task
Waiting...OK
>> File "src\scss\core\_mixins.scss" changed.
Running "compass:groundwork" (compass) task
Warning: Task "compass:groundwork" failed. Use --force to continue.

Aborted due to warnings.

I did on purpose a invalid syntax to see if the stack trace would show up, but it didnt. The config.rb is a clean slate one, and the Gruntfile.coffee part is merely config: 'config.rb, trace: true`

Warn or fail on error

Shouldn't the task warn or fail on a compass compile error? Is this a config variable I might have missed? In the private compile() callback, the call to cb() will pass either a boolean or result.stderr. In my case, stderr only includes color characters, or nothing if the boring option is set.

Soft refresh for CSS

Is it possible to have grunt-contrib-compass configured so that css (compiled from sass) is softly updated on the browser? Currently im getting a page-reload with the following config:

regarde: {
      txt: {
        files: ['src/sass/*.*', 'src/js/*.coffee', 'index.html'],
        tasks: ['coffee','compass','livereload']
      }
    },

Sprite generated imaged listed multiple times in Compass task

I have grunt-contrib-compass triggered by regarde task, and im using compass to generate a simple sprite.

My only issue with this is that the image generated by compass is listed multiple times:
http://cl.ly/image/3j3r1P2r3K3s

The sprite is composed of 7 individual images, exactly the same number of times it is listed in the screenshot above.

I've also created a gist with my current Gruntfile.js:
https://gist.github.com/lmartins/5433896

Any suggestions?

Compass create command required ?

I just switch a project from 0.3 to 0.4 (so grunt-compass to grunt-contrib-compass).
But if I don't have any config.rb, it seems it doesn't work :(

Here is my config.

        compass: {
            dev: {
                sassDir: 'src/_styles',
                cssDir: 'build/css',
                outputStyle: 'expanded',
                noLineComments: false,
                debugInfo: true,
                relativeAssets: true
            },
            dist: {
                sassDir: 'src/_styles',
                cssDir: 'build/css',
                outputStyle: 'compressed',
                noLineComments: true,
                force: true,
                relativeAssets: true
            }
        },

Did I miss something ?

Performance

I have the most basic setup with compass_twitter_bootstrap + font-awesome as follows:

$ ls -R app/styles/
_compass_twitter_bootstrap.scss         font
_compass_twitter_bootstrap_awesome.scss     lists.scss
_compass_twitter_bootstrap_responsive.scss  main.scss
cart.scss                   menu.scss
compass_twitter_bootstrap           testing.scss

main.scss

@import "compass_twitter_bootstrap_awesome";
@import "compass_twitter_bootstrap_responsive";
@import "lists";
@import "cart";
@import "menu";
@import "testing";

Gruntfile.js

compass: {
  options: {
    sassDir: 'app/styles',
    cssDir: '.tmp/styles'
  },
  server: {
    options: {
      specify: ['app/styles/main.scss']
    }
  }
},
// note: watch is actually regarde
watch: {
  compass: {
    files: ['app/styles/**/*.{scss,sass}'],
    tasks: ['compass:server']
  }
}

And finally, main.css is included in index.html.

compass:server takes usually 3-4 seconds.

I've made sure to @import only the needed subset of compass in the .scss files.

It's pretty painful to try and develop with livereloading. Is there something we can do to make this faster?

Even with bootstrap removed, my very small SCSS codebase takes up to 1 second to compile.

With specify: ['app/styles/empty.scss'], compass task is taking around 600ms so there seems to be quite a lot of overhead just to run the task.

The grunt task does not propagate error code from compass when using an invalid argument

When running our grunt tasks on my computer the compass tasks compiled fine. When running the same tasks on our server the tasks returned an "invalid option: --fonts-dir" (see below) since the server had an older version of compass (without that option). Since the grunt-contrib-compass grunt task did not propagate the error code, the error was not detected (our "grunt build" did not fail, and the Jenkins job did not fail).

I reproduced the error by adding an invalid option in Gruntfile.js:

    (...)
    compass: {
        options: {
            sassDir: '<%= yeoman.app %>/styles',
            cssDir: '.tmp/styles',
            imagesDir: '<%= yeoman.app %>/images',
            javascriptsDir: '<%= yeoman.app %>/scripts',
            fontsDir: '<%= yeoman.app %>/styles/fonts',
            importPath: '<%= yeoman.app %>/components',
            thisIsAnInvalidOption: 'myInvalidArgument',
            relativeAssets: true
        },
        dist: {},
        server: {
            options: {
                debugInfo: true
            }
        }
    },
    (...)

Console ouput:

$ grunt compass:dist
Running "compass:dist" (compass) task
Error: invalid option: --this-is-an-invalid-option
(...)
$ echo $?
0

I added a console.log inside the compile function:

  (...)
  function compile(args, cb) {
    var child = grunt.util.spawn({
      cmd: args.shift(),
      args: args
    }, function (err, result, code) {
      if (code === 127) {
    return grunt.warn(
      'You need to have Ruby and Compass installed ' +
      'and in your system PATH for this task to work. ' +
      'More info: https://github.com/gruntjs/grunt-contrib-compass'
    );
      }
      // `compass compile` exits with 1 when it has nothing to compile
      // https://github.com/chriseppstein/compass/issues/993
      console.log(arguments);
      cb((code === 0 || !/Nothing to compile/g.test(result.stdout)) || result.stderr);
    });
    child.stdout.pipe(process.stdout);
    child.stderr.pipe(process.stderr);
  }
  (...)

Output from inside the function

{ '0': [Error],
  '1': 
   { stdout: 'Error: invalid option: --this-is-an-invalid-option\n\nUsage: compass compile [path/to/project] [path/to/project/src/file.sass ...] [options]\n\nDescription:\ncompile project at the path specified or the current director if not specified.\n\nOptions:\n        --time                       Display compilation times.\n        --debug-info                 Turns on sass\'s debuging information\n        --no-debug-info              Turns off sass\'s debuging information\n    -r, --require LIBRARY            Require the given ruby LIBRARY before running commands.\n                                       This is used to access compass plugins without having a\n                                       project configuration file.\n    -l, --load FRAMEWORK_DIR         Load the framework or extensions found in the FRAMEWORK directory.\n    -L, --load-all FRAMEWORKS_DIR    Load all the frameworks or extensions found in the FRAMEWORKS_DIR directory.\n    -I IMPORT_PATH                   Makes files under the IMPORT_PATH folder findable by Sass\'s @import directive.\n    -q, --quiet                      Quiet mode.\n        --trace                      Show a full stacktrace on error\n        --force                      Allows compass to overwrite existing files.\n        --dry-run                    Dry Run. Tells you what it plans to do.\n        --boring                     Turn off colorized output.\n    -c, --config CONFIG_FILE         Specify the location of the configuration file explicitly.\n        --app APP                    Tell compass what kind of application it is integrating with. E.g. rails\n        --sass-dir SRC_DIR           The source directory where you keep your sass stylesheets.\n        --css-dir CSS_DIR            The target directory where you keep your css stylesheets.\n        --images-dir IMAGES_DIR      The directory where you keep your images.\n        --javascripts-dir JS_DIR     The directory where you keep your javascripts.\n        --fonts-dir FONTS_DIR        The directory where you keep your fonts.\n    -e, --environment ENV            Use sensible defaults for your current environment.\n                                       One of: development (default), production\n    -s, --output-style STYLE         Select a CSS output mode.\n                                       One of: nested, expanded, compact, compressed\n        --relative-assets            Make compass asset helpers generate relative urls to assets.\n        --no-line-comments           Disable line comments.\n    -?, -h, --help                   Show this message',
     stderr: '',
     code: 1,
     toString: [Function] },
  '2': 1 }

Original error output (from Jenkins job):

Running "compass:dist" (compass) task
Error: invalid option: --fonts-dir

Usage: compass compile [path/to/project] [path/to/project/src/file.sass ...] [options]

Description:
compile project at the path specified or the current director if not specified.

Options:
    --time                       Display compilation times.
    -r, --require LIBRARY            Require the given ruby LIBRARY before running commands.
                                   This is used to access compass plugins without having a
                                   project configuration file.
    -l, --load FRAMEWORK_DIR         Load the framework or extensions found in the FRAMEWORK directory.
    -L, --load-all FRAMEWORKS_DIR    Load all the frameworks or extensions found in the FRAMEWORKS_DIR directory.
    -q, --quiet                      Quiet mode.
    --trace                      Show a full stacktrace on error
    --force                      Allows some failing commands to succeed instead.
    --dry-run                    Dry Run. Tells you what it plans to do.
    --boring                     Turn off colorized output.
    -c, --config CONFIG_FILE         Specify the location of the configuration file explicitly.
    --app APP                    Tell compass what kind of application it is integrating with. E.g. rails
    --sass-dir SRC_DIR           The source directory where you keep your sass stylesheets.
    --css-dir CSS_DIR            The target directory where you keep your css stylesheets.
    --images-dir IMAGES_DIR      The directory where you keep your images.
    --javascripts-dir JS_DIR     The directory where you keep your javascripts.
    -e, --environment ENV            Use sensible defaults for your current environment.
                                   One of: development (default), production
    -s, --output-style STYLE         Select a CSS output mode.
                                   One of: nested, expanded, compact, compressed
    --relative-assets            Make compass asset helpers generate relative urls to assets.
    --no-line-comments           Disable line comments.
    -?, -h, --help                   Show this message

Failing on compile error

This is basically a dupe of #12, but seems like my comment there has been ignored.

Anyway, the problem is that the compile task doesn't fail correctly when there is a CSS error.
Would you consider a pull request to fix this issue, or are you ignoring it completely until it is standardized?

httpFontsDir throws an invalid options error

Gruntfile:

dist {
  options: {
    httpFontsDir: '/styles/fonts'
  }
}

Output:

Running "compass:dist" (compass) task                                                                                                                                                                                                            │Chrome 26.0 (Mac): Executed 168 of 168 SUCCESS (0.643 secs / 0.56 secs)
Error: invalid option: --http-fonts-dir

Error: invalid option: --base-path

Config:

compass:
  dev:
    options:
      basePath: "assets"
      require: "zurb-foundation"
      cssDir: "assets/stylesheets"
      sassDir: "assets/sass"
      images: "assets/images"
      fontsDir: "assets/fonts"

  prod:
    options:
      basePath: "assets"
      require: "zurb-foundation"
      cssDir: "assets/stylesheets"
      sassDir: "assets/sass"
      imagesDir: "assets/images"
      fontsDir: "assets/fonts"
      outputStyle: "compact"

Grunt error:

Running "compass:dev" (compass) task
Error: invalid option: --base-path

Compass:

compass -v
Compass 0.12.2 (Alnilam)

Grunt:

grunt --version
grunt-cli v0.1.6
grunt v0.4.0rc7
grunt-contrib-compass ~0.1.1rc7

Missing Specify Argument.

Need to compass compile a single file - which is easily done by running compass compile sass/file.scss.

An optional parameter to pass a specific source file for compile is needed.

Wrong css output

I updated the latest version of grunt (0.4.1) and installed the compass package (grunt-contrib-compass). Here the config I use:

compass: {                  
  dist: {                   
    options: {              
      sassDir : "src/theme/sass",
      cssDir : "src/theme/css",
      imagesDir: "src/theme/img",
      javascriptsDir : "src/js",
      fontsDir : "src/theme/fonts",
      environment : "production"
    }
  }
}

Every time a change occurres in the sass directory, the compass task is executed and the css directory is created (with the production css files). Everything is good but the css files, the config.rb files and the sass cache are also recopied in the sass directory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.