Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding sourcemaps #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/ScssAssetConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ class ScssAssetConverter extends Component implements AssetConverterInterface
const FORMAT_EXPANDED = \Leafo\ScssPhp\Formatter\Expanded::class;
const FORMAT_NESTED = \Leafo\ScssPhp\Formatter\Nested::class;

/**
* Source maps constant from Leafo\ScssPhp\Compiler
*/
const SOURCE_MAP_NONE = Compiler::SOURCE_MAP_NONE;
const SOURCE_MAP_INLINE = Compiler::SOURCE_MAP_INLINE;
const SOURCE_MAP_FILE = Compiler::SOURCE_MAP_FILE;

/**
* @var Storage
*/
Expand All @@ -40,6 +47,27 @@ class ScssAssetConverter extends Component implements AssetConverterInterface
* @var string|\Leafo\ScssPhp\Formatter
*/
public $formatter = \Leafo\ScssPhp\Formatter\Nested::class;

/**
* @var integer Enable/disable source maps
* self::SOURCE_MAP_NONE - disable source maps generator
* self::SOURCE_MAP_INLINE - source maps generate inside complied css file
* self::SOURCE_MAP_FILE - generate source maps file
*
* e.g:
* new ScssAssetConverter([
* 'sourceMap' => ScssAssetConverter::SOURCE_MAP_INLINE,
* 'sourceMapOptions' => [
* 'sourceMapBasepath' => '\',
* 'sourceRoot' => '\',
* ],
* ]);
*/
public $sourceMap = self::SOURCE_MAP_NONE;
/**
* @var array Source maps options
*/
public $sourceMapOptions = [];

/**
* @var Compiler SCSSPHP Compiler object which does the actual work
Expand All @@ -56,6 +84,10 @@ public function init()
/** @var Compiler $compiler */
$compiler = Yii::createObject(Compiler::class);
$compiler->setFormatter((string) $this->formatter);

$compiler->setSourceMap($this->sourceMap);
$compiler->setSourceMapOptions($this->sourceMapOptions);

$this->compiler = $compiler;
}

Expand Down