PHPackages                             mrkmg/native-sass - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. mrkmg/native-sass

ActiveLibrary

mrkmg/native-sass
=================

A native sass wrapper

1.0.1(11y ago)322MITPHPPHP &gt;=5.3.0

Since Apr 13Pushed 11y ago1 watchersCompare

[ Source](https://github.com/mrkmg/NativeSass)[ Packagist](https://packagist.org/packages/mrkmg/native-sass)[ RSS](/packages/mrkmg-native-sass/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

NativeSass
==========

[](#nativesass)

NativeSass will compile your sass and scss files using the sass command on your system. It allows for a variety of options and comes with a ServiceProvider for Laravel.

Installation
------------

[](#installation)

First, ensure that Sass is installed on your system. To do that see [Sass Install](http://sass-lang.com/install).

Next, install NativeSass via composer.

```
composer require mrkmg/native-sass

```

***With Laravel 4***

Add the service provider to your app config (app/config/app.php)

```
'mrkmg\NativeSass\CompilerServiceProvider'

```

Install the configuration file

```
php artisan config:publish mrkmg/native-sass

```

Update the configuration file to your needs.

Usage
-----

[](#usage)

***Generic Usage***

Instantiate a new instance of the compiler with the desired options.

```
$compiler = new \mrkmg\NativeSass\Compiler([
    'compilerPath'  => 'sass',
    'inputPath'     => '/some/path/to/raw/sass',
    'outputPath'    => '/some/path/for/compiled/css',
    'outputStyle'   => 'expanded', //Options are nested, compact, compressed, or expanded
    'sourceMap'     => 'file', //Options are auto, inline, file, or none
]);

```

For all the following examples, if you pass a relative path, it is assumed to be relative to the `inputPath`. If you pass an absolute path (any path starting with a /) then the path is used as is.

If you wish to compile a single file into CSS, use the `compileSingle` method.

```
//Keep the same name. Will create rawfile.css and rawfile.css.map in the outputPath
$compiler->compileSingle('rawfile.sass');

//Custom output name and paths. Will create newname.css and newname.css.map in /some/other/output/
$compiler->compileSingle('/some/other/path/rawfile.scss', '/some/other/output/newname.css');

```

You can also compile many files at once. Use the `compileMany` method which takes an array of files.

```
//Compiles many files.
$compiler->compileMany([
    'rawfile.sass',
    'rawfile2.sass',
    'rawfile3.sass' => 'alternatename.css'
]);

```

Finally, you can compile an entire directory of CSS files all at once with the `compileAll` method. By default, only files in the top directory are compiled.

```
//Compiles all files in the inputPath into the outputPath
$compiler->compileAll();

//Compiles all files in a specific directory into the outputPath
$compiler->compileAll('/some/other/sourcedir/');

//Compile all files in the inputPath, and 2 levels deep of sub-directories, into the outputPath
$compiler->compileAll("", 2);

```

***With Laravel***

The class in instantiated automatically and all methods made available via the alias NativeSass.

For example, to run compile a single file:

```
NativeSass::compileSingle('rawfile.sass');

```

Usage is the same as above.

Optional Command for Laravel 4
------------------------------

[](#optional-command-for-laravel-4)

If you wish to compile all your sass via a console command in artisan, create the following command:

Create app/command/CompileSass.php

```
