Giter Club home page Giter Club logo

grunt-csscomb's Introduction

DEPRECATED

This version of CSScomb is no longer supported, guys.
We have a new super cool Node.js version instead!

Tool for sorting CSS properties

  • Sorts CSS properties into a logical, consistent order
  • Allows for custom sorting of CSS properties (set it to whatever order you're accustomed to)
  • Parses CSS in style tags and style attributes -- can comb other languages for CSS as well
  • Does not change existing formatting of style sheets --target single or multiple lines of CSS
  • Separates CSS properties into groups (you can have groups of empty strings, if you want)
  • Fully supports CSS2/CSS2.1/CSS3

The CSScomb algorithm simulates a web developer's judgment in ordering CSS styles. You can spend tons of time re-ordering code--moving lines over each other, working around comments in the code, moving multi-line sets of property values, and all sorts of hacking to make your code more readable. CSScomb takes care of these tasks for you. It "thinks" like a person editing the text, not as a blind robot parsing CSS.

CSScomb.com

The Requirements

CSScomb is written in pure PHP, without any external libraries or dependencies. See details at wiki.

  • Sublime Text 2 plugin avaliable in Package Control as 'CSScomb'
  • TextMate plugin
  • Coda plugin
  • Coda 2 plugin
  • Espresso 2 plugin (How to install)
  • IntelliJIDEA plugin
  • WebStorm plugin
  • PyCharm plugin
  • Notepad ++ plugin
  • Chocolat Mixin
  • Vim Plugin

CLI usage

Available at csscomb.com

% php csscomb.php

CSSComb
Command line tool for resort CSS code.

SYNOPSIS
    $ php csscomb.php -s <file with JSON array> -i <path to input css file> -o <path to result css file>

DESCRIPTION
    options:
    -s, --sort-order    specify file with custom sort order. File must contain JSON data. For detail information run 'csscomb.php --help-sort-order'
    -i, --input         must be directory name or file that needs to be sorted
    -o, --output        sort result file. Use output when input is not a directory name, otherwise output param ignored. If output filename does not exist, the file is created. Otherwise, the existing file is overwritten.

    --help, -help, -h, -? or no options will print this man.

EXAMPLE
    csscomb.php -s my-custom-sort-order.json -i css/style.css -o css/style-resorted.css

EXAMPLE 2
    csscomb.php -i some_directory_name

Twitter

@csscomb

grunt-csscomb's People

Contributors

garthenweb avatar noahcooper avatar oswaldoacauan avatar t32k avatar tonyganch 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

grunt-csscomb's Issues

Large files not running task

I have 20 files in a folder. Most are about 500 lines others are about 1000-2400 and one is 5000. It will not comb the 5000 line file at all. It says it worked and no errors, but it isn't changing the files at all.

Any files after the large file do not run either unless I exclude the large file.

Support directories

Today to comb a whole directory(1-1) we need something like this

files: [{
  expand: true,
  cwd: '/assets/css',
  src: ['**/*.css'],
  dest: '/assets/css',
  filter: 'isFile'
}]

Maybe we can add a support to diretories, since comb.js have processDirectory to do most of the work for us

files: [
  '/assets/css'
]

In SASS, I can't @extend from a class with a number in it

When trying to run csscomb on a folder of scss files, I've noticed that I get an error whenever I @extend from a class with a number in it. For example:

.footer-nav {
    > li {
        @extend .col-md-4;
    }
}

Everywhere else I use @extend works fine, and and so does this when I remove the number at the end of .col-md-4. Did I perhaps overlook something in my settings, or is this an issue with the plugin?

@include parse error in SASS (SCSS)

I get the Error:

Warning: Parsing error: Please check the validity of the CSS block starting from the line 16 Use --force to continue.

The line 16 has this property:

@include border-radius($defaultBorderRadius/2);

The problem seems to be the math part. If I remove th /2, there is no problem.
So this would work:

@include border-radius($defaultBorderRadius);

loop tasks

Config Gruntfile:

    // Sorting CSS properties in specific order.
    csscomb: {
      options: {
        config: '.csscomb.json'
      },
      dynamic: {
        expand: true,
        cwd: 'src/less/',
        src: ['**/*.less'],
        dest: 'src/less/',
        ext: '.less'
      }
    },

When a file change:

    // Waiting
    watch: {
      options: {
        nospawn: true
      },
      styles: {
        files: ['src/less/**/*.less'],
        tasks: ['less:development', 'csscomb', 'notify:less_true']
      },

Strange behavior:
tdtunwg 1

What am I doing wrong? Please, tell me. Thank you.

Not sure how to make CSSComb plugin sort without unminifying the CSS

I've got a Compass compiled CSS with the "compressed" option set as layout.

If I run CSSComb on it, it sorts everything nicely, but adds all the line-breaks and indentation back on the file.

Is there a way to add a .csscombrc or some sort of file name that I wouldn't need to link the configurations on my Gruntfile.js? If there's not, what options should I use in order to stop this expanding process and how would I link the config file on the Grunt plugin?

Thanks.

Ignoring indentations

Csscomb seems to ignore my indentations. I am using sass so indentations are very important :

Before :
csscomb_before

After :

csscomb_after

I am using 4 tab indentations.

Thank you!

Using * in files

If you want to do every file in a directory with file extension ".css" or ".scss" - there is no way (assuming you'd keep the same file name or provide on option to prepend/append/regex the filename).

Doesn't work as default task

You have to define a subtask - running CSSComb task with just "files" defined doesn't work.

Works:

csscomb: {
    maintask: {
        files: {
            '../assets/scss/file.scss': ['../assets/scss/file.scss']
        }
    }
}

Doesn't work:

csscomb: {
    files: {
        '../assets/scss/file.scss': ['../assets/scss/file.scss']
    }
}

Make all CSSComb options available

There is a way to specify all CSSComb options? Via a .csscombrc file maybe?

The sortOrder is not the only option i want to customize, since CSSComb.js have a bunch of nice configurable features.

Maximum call stack size exceeded in 1.2.0

Downgrading to 1.1.0 is the only work around for now. In 1.2.0 I am seeing Maximum call stack size exceeded. OS X 10.8.5, Node 0.10.24, NPM 1.3.22.

/var/www/test $ grunt csscomb --verbose
Initializing
Command-line options: --verbose

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.
Initializing config...OK

Registering "grunt-csscomb" local Npm module tasks.
Reading /private/var/www/test/node_modules/grunt-csscomb/package.json...OK
Parsing /private/var/www/test/node_modules/grunt-csscomb/package.json...OK
Loading "csscomb.js" tasks...OK
+ csscomb
Loading "Gruntfile.js" tasks...OK
>> No tasks were registered or unregistered.

Running tasks: csscomb

Running "csscomb" task

Running "csscomb:foo" (csscomb) task
Verifying property csscomb.foo exists in config...OK
Files: foo.css -> bar.css
Options: (none)
Warning: Maximum call stack size exceeded Use --force to continue.

Gruntfile.js

module.exports = function(grunt) {

    grunt.initConfig({
        csscomb: {
            foo: {
                files: {
                    'bar.css': ['foo.css'],
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-csscomb');

};

packages.json

{
  "name": "test",
  "version": "0.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "grunt-csscomb": "~1.2.0"
  }
}

Не происходит сортировка

У меня не получается заставить работать этот плагин.

Мой Gruntfile.js выглядит так:

module.exports = function(grunt) {

  grunt.initConfig({
    csscomb: {
      main: {
        options: {
          sortOrder: '.csscomb.json'
        },
        files: {
          'main.css': ['result.css']
        },
      },
    },
  });

  grunt.loadNpmTasks('grunt-csscomb');

  grunt.registerTask('default', ['csscomb']);
};

После запуска Grunt в консоли я получаю следующий результат:

e:\test\dev>grunt
Running "csscomb:main" (csscomb) task
>> Using custom config file ".csscomb.json"...

Done, without errors.

При этом с файлом main.css (он лежит в одной директории с Gruntfile.js) ничего не происходит.
Что именно я делаю не так?

1.2.x breaks compilation order

We recently updated to 1.2.1 (from 1.1.0) and were seeing an incorrect compilation order:

➜ ~/Sites/bootstrap (master) git diff
diff --git a/dist/css/bootstrap-theme.css b/dist/css/bootstrap-theme.css
index b092f82..398c856 100644
--- a/dist/css/bootstrap-theme.css
+++ b/dist/css/bootstrap-theme.css
@@ -38,11 +38,12 @@
   text-shadow: 0 1px 0 #fff;
   background-image: -webkit-linear-gradient(top, #fff 0%, #e0e0e0 100%);
   background-image:         linear-gradient(to bottom, #fff 0%, #e0e0e0 100%);
-  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe0e0e0', GradientType=0);
-  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
   background-repeat: repeat-x;
   border-color: #dbdbdb;
   border-color: #ccc;
+
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe0e0e0', GradientType=0);
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
 }
 .btn-default:hover,
 .btn-default:focus {
@@ -57,10 +58,11 @@
 .btn-primary {
   background-image: -webkit-linear-gradient(top, #428bca 0%, #2d6ca2 100%);
   background-image:         linear-gradient(to bottom, #428bca 0%, #2d6ca2 100%);
-  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff2d6ca2', GradientType=0);
-  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
   background-repeat: repeat-x;
   border-color: #2b669a;
+
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff2d6ca2', GradientType=0);
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
 }

The PR that did the update was twbs/bootstrap#11959, for reference.

The filter properties should be where they initially were. This happens with 1.2.0 and 1.2.1. Nuking my node_modules and rerunning npm install resolves the issue.

Any idea what happened? Nothing in our CSS order has changed.

Lint option is not available

Hi t32k, many thanks for your work on adaptation of csscomb for grunt.

I want to let you know that there is no way to use lint option for csscomb,
because it's implemented only as cli attributes.
it would be good if this option could be moved to options object,
or even to .csscomb.json config file (not sure that this issue should be placed in this thread)

Use semantic versioning

I propose that current master branch gets version 2.0.0 because it is not backwards compatible with version 1.1.0.

If the plugin's API changes dramatically (for example, when sortOrder option is renamed to config), there should be a major version update.
See http://semver.org.

We have a lot of users and for many of them csscomb is a serious development tool.
Thus we are responsible to make our releases as stable and predictable as possible.
Since semantic versioning is a common and expected thing, I propose using it.

Confusion on setting options

Hey there, we're looking at moving Bootstrap from Recess to CSScomb, but hitting a snag. For some reason I cannot load any custom options. Pointing the sort-order option to the included json example doesn't seem to have any effect.

...
    csscomb: {
      options: {
        sortOrder: '.csscomb.json',
      },
      files: {
        'dist/css/<%= pkg.name %>.css': ['dist/css/<%= pkg.name %>.css'],
      }
    },
...

I know there is no effect because I'm pointing that option to .csscomb.json and "vendor-prefix-align": true has no effect.

Guess I'm just missing something?

Output has rogue spaces

Using raw grunt-contrib-less, I get this diff on Bootstrap:

 sub,
 sup {
-  position: relative;
   font-size: 75%;
   line-height: 0;
+  position: relative;
   vertical-align: baseline;
 }

With grunt-csscomb, I get some rogue spaces:

 sub,
 sup {
-  position: relative;
   font-size: 75%;
   line-height: 0;
+
+  position: relative;
+
   vertical-align: baseline;
 }

Things get even worse with media queries (there are no changes in the default LESS compilation task):

 @media print {
-  * {
+    * {
     color: #000 !important;
-    text-shadow: none !important;
     background: transparent !important;
     box-shadow: none !important;
-  }
-  a,
+    text-shadow: none !important;
+    }
+    a,
   a:visited {
     text-decoration: underline;
-  }
-  a[href]:after {
+    }
+    a[href]:after {
     content: " (" attr(href) ")";
-  }
-  abbr[title]:after {
+    }
+    abbr[title]:after {
     content: " (" attr(title) ")";
-  }
-  a[href^="javascript:"]:after,
+    }
+    a[href^="javascript:"]:after,
   a[href^="#"]:after {
     content: "";
-  }

Is this a problem with grunt-csscomb, or the source CSScomb?

console.warn stops CSScomb

If for some reason there is an unacceptable value in user's config, CSScomb prints a warning to console:

try {
    addHandler(options[optionName], config[optionName]);
 } catch (e) {
    // Show warnings about illegal config values only in verbose mode:
    if (verbose) {
        console.warn('\nFailed to configure "%s" option:\n%s', optionName, e.message);
    }
}

Errors are thrown within setValue function: https://github.com/csscomb/core/blob/master/lib/core.js#L101

@corvannoorloos says that instead of just printing a warning Grunt plugin also "discontinues the task (the files aren't being modified after this notice)".

task not sorting, what I'm doing wrong?

I have such CSScomb.json in the root of the project. Also I have css-file with path like this static/desktop.bundles/wizard/blocks/wizard-steps/wizard-steps.css. Also task is configured this way:

csscomb: {
    options: {
        config: 'CSScomb.json'
    },
    all: {
        expand: true,
        cwd: 'static/',
        src: [ '**/*.css' ],
        dest: 'static/'
    }
}

When I run CSScomb with $ grunt csscomb:all task logs sorting wizard-steps.css:

>> Sorting file "static/desktop.bundles/wizard/blocks/wizard-steps/wizard-steps.css"...

But original state of this file is:

 .wizard-steps
{
    margin: 50px 0 0;
    display: block;
}

and it's not changed via grunt-csscomb, but when I sort this file with Sublime CSScomb it changed to normal and expected state:

.wizard-steps
{
    display: block;

    margin: 50px 0 0;
}

What I'm doing wrong?

Support csscomb.js

We have a node version of csscomb ready.
It will be nice if this grunt task is updated by the time of public release.

If someone starts working on this issue, please leave a comment.
Keep in mind that current (php) version should stay available for download.
The easiest way is to make a release before making any changes.
Thank you.

3.0.0-1 issue

 .content {
   background-color: #efeff4;
-}
+  }

Going back to the old version outputs proper code so this is something introduced in csscomb.js 3.0.0.

Publish new version to npm

@t32k, hi!
I've released [email protected] a few days ago so others can start testing it.
Some of our wonderful users have asked to publish grunt task, too.
Could you please take a look at branch tg/csscomb-3 and if you are ok with those changes, publish it to npm as a pre-release?
There is no need to merge the branch to master since it can't be called stable yet.

Please implement with pure nodejs

I want to use grunt-csscomb in Travis CI,
but current version depends on PHP.
it's more better that grunt-csscomb is available without PHP, i think.

Dynamic mapping - overwriting same file

Hello,

Is there a way to overwrite the file that was found with the watch task :

So if I save a _scss file that is in : assets/styles/src/objects/_btn.scss, it will ignore the destination file because it will just overwrite the file that was saved.

csscomb: {
    foo: {
        files: {
            'assets/styles/src/**/*.scss': ['assets/styles/src/**/*.scss']
        }
    }
},
watch: {
css: {
    files: ['assets/styles/src/**/*.scss'],
    tasks: ['sass', 'csscomb'],
    options: {
        spawn: false,
    }
},
 }

Thank you !

Suport for sass/scss

When i to run task on my scss files i recieve such errors:

Running "csscomb:dynamic_mappings" (csscomb) task
>> Using default config file...
>> Source file "main.scss" not found.
>> Source file "modules/_mixins.scss" not found.
>> Source file "modules/_typography.scss" not found.
>> Source file "modules/_variables.scss" not found.
....

i am using such options

    csscomb:
      dynamic_mappings:
        cwd: '<%= yeoman.dist %>/styles/'
        src: ['*.scss']
        dest: '<%= yeoman.dist %>/styles/compressed'
        ext: '.resorted.scss'

with css files with such options csscomb works fine.

Or csscomb currently not supporting preprocessors?

Multiple sources do not work as expected

If we mention list of souces for one file we expect concatination of results but we get only last souce file cleaned up with csscomb in dst.css

csscomb: {
    main: {
        files: {
            'dst.css': ['src1.css', 'src2.css'],
        }
    },

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.