Giter Club home page Giter Club logo

grunt-prettysass's Introduction

grunt-prettysass

Prettify and alphabetize your SASS source files.

Getting Started

This plugin requires Grunt ~0.4.0

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-prettysass --save-dev

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

grunt.loadNpmTasks('grunt-prettysass');

The "prettysass" task

Overview

In your project's Gruntfile, add a section named prettysass to the data object passed into grunt.initConfig().

grunt.initConfig({
  prettysass: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
})

Options

options.alphabetize

Type: Boolean Default value: false

Sort SASS properties alphabetically.

options.indent

Type: mixed Default value: 2

How many spaces to use for each level of indentation. Defaults to 2. "t" means use hard tabs.

Usage Examples

To run prettysass and alphabetize properties on all files in your scss directory. You can define source files individually in an array or use a globbing pattern as shown below:

grunt.initConfig({
  prettysass: {
    options: {
      alphabetize: true
    },
    app: {
      src: ['scss/**/*.scss']
    },
  },
})

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)

grunt-prettysass's People

Contributors

brandonminch avatar

Stargazers

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

Watchers

 avatar  avatar

grunt-prettysass's Issues

Problem with @content includes

This is a really great Module!

But I found a problem with includes:

%placeholder {
  @include breakpoint(xs) {
    width: $value1;
  }
  width: $value2;
  flex-shrink: 0;
}  

outputs this:

%placeholder {
  @include breakpoint(xs) {
  flex-shrink: 0;
  width: $value2;
    width: $value1;
  }
}

Which is very strange. I use includes with @content a lot and it works fine except in this case. I can't figure out why it happens here. Any ideas whats going wrong?

Add option to remove blank lines from output

Hello,

Allow me to begin by expressing my gratitude for the existence of this grunt plugin. Of all those I've tried this is the only one that I've been able to use to automatically format (or, "prettify") my Sass code.

I've modified prettysass.js a bit to add an option to remove blank lines from the output.

Here's my modified version of prettysass.js:

http://websightdesigns.com/prettysass.txt

Just let me know if there's anything I need to do on my end to commit this into the repository.

sass-convert not found

The prettysass task fails:

Running "prettysass:app" (prettysass) task
prettifying: ./sass
>> ./sass: Error: Command failed: /bin/sh: sass-convert: command not found
Warning: Task "prettysass:app" failed. Use --force to continue.

On OS X 10.10 Yosemite.

I installed the package exactly as the README said: npm install grunt-prettysass --save-dev.
My grunt version is:

> grunt --version
grunt-cli v0.1.13
grunt v0.4.5

My grunt config is available here: https://gist.github.com/ChristianSch/84368e2e4e7e9ecba753#file-gruntfile-js-L108

The command sass-convert is not available (globally). So this fails: https://github.com/brandonminch/grunt-prettysass/blob/master/tasks/prettysass.js#L164

I don’t know if the README is missing something or my installation is flawed but any suggestions would be great.

List Ruby Sass as a dependency for grunt-prettysass

Since grunt uses the command sass-convert which comes with the ruby version of Sass, it makes sense to mention that in the README.md file, because otherwise, people who are using node-sass will get an error indicating that the command sass-convert is not found.

Fixing problem with alphabetization

First of all, great module!
I have a problem when I activate alphabetization with scss files which are structured like that:

#page {
position: relative;
.next, 
.prev {
width: 100;
}
}

When i run prettysass over this code, I get the following output:

#page {
.next, 
position: relative;
.prev {
width: 100;
}
}

So it seems that if you use a new line for each class or id, the module thinks it is an attribute and sorts it. It have no problems with classes and ids in one line.

Would be great if you can take a look.

Newlines inserted before inline comments

This plugin is great, but it inserts two newlines before every inline comment. Is there an option to keep the inline comments inline? If not, this would be a nice feature to add.

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.