Allow combine scss files from command.
This commit is contained in:
parent
1a41f632bc
commit
cf1fda7437
|
|
@ -176,6 +176,7 @@ class CombineAssets
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the combined contents from a prepared cache identifier.
|
* Returns the combined contents from a prepared cache identifier.
|
||||||
|
* @param string $cacheKey Cache identifier.
|
||||||
* @return string Combined file contents.
|
* @return string Combined file contents.
|
||||||
*/
|
*/
|
||||||
public function getContents($cacheKey)
|
public function getContents($cacheKey)
|
||||||
|
|
@ -212,7 +213,7 @@ class CombineAssets
|
||||||
/**
|
/**
|
||||||
* Prepares an array of assets by normalizing the collection
|
* Prepares an array of assets by normalizing the collection
|
||||||
* and processing aliases.
|
* and processing aliases.
|
||||||
* @param $assets array
|
* @param array $assets
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function prepareAssets(array $assets)
|
protected function prepareAssets(array $assets)
|
||||||
|
|
@ -284,8 +285,8 @@ class CombineAssets
|
||||||
/**
|
/**
|
||||||
* Combines asset file references of a single type to produce
|
* Combines asset file references of a single type to produce
|
||||||
* a URL reference to the combined contents.
|
* a URL reference to the combined contents.
|
||||||
* @var array List of asset files.
|
* @param array $assets List of asset files.
|
||||||
* @var string File extension, used for aesthetic purposes only.
|
* @param string $localPath File extension, used for aesthetic purposes only.
|
||||||
* @return string URL to contents.
|
* @return string URL to contents.
|
||||||
*/
|
*/
|
||||||
protected function prepareRequest(array $assets, $localPath = null)
|
protected function prepareRequest(array $assets, $localPath = null)
|
||||||
|
|
@ -335,6 +336,8 @@ class CombineAssets
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the combined contents from a prepared cache identifier.
|
* Returns the combined contents from a prepared cache identifier.
|
||||||
|
* @param array $assets List of asset files.
|
||||||
|
* @param string $rewritePath
|
||||||
* @return string Combined file contents.
|
* @return string Combined file contents.
|
||||||
*/
|
*/
|
||||||
protected function prepareCombiner(array $assets, $rewritePath = null)
|
protected function prepareCombiner(array $assets, $rewritePath = null)
|
||||||
|
|
@ -394,6 +397,7 @@ class CombineAssets
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a deep hash on filters that support it.
|
* Returns a deep hash on filters that support it.
|
||||||
|
* @param array $assets List of asset files.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function getDeepHashFromAssets($assets)
|
protected function getDeepHashFromAssets($assets)
|
||||||
|
|
@ -442,6 +446,7 @@ class CombineAssets
|
||||||
* /combine returns combine/
|
* /combine returns combine/
|
||||||
* /index.php/combine returns index-php/combine/
|
* /index.php/combine returns index-php/combine/
|
||||||
*
|
*
|
||||||
|
* @param string|null $path
|
||||||
* @return string The new target path
|
* @return string The new target path
|
||||||
*/
|
*/
|
||||||
protected function getTargetPath($path = null)
|
protected function getTargetPath($path = null)
|
||||||
|
|
@ -488,7 +493,7 @@ class CombineAssets
|
||||||
* Register a filter to apply to the combining process.
|
* Register a filter to apply to the combining process.
|
||||||
* @param string|array $extension Extension name. Eg: css
|
* @param string|array $extension Extension name. Eg: css
|
||||||
* @param object $filter Collection of files to combine.
|
* @param object $filter Collection of files to combine.
|
||||||
* @return Self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function registerFilter($extension, $filter)
|
public function registerFilter($extension, $filter)
|
||||||
{
|
{
|
||||||
|
|
@ -515,7 +520,7 @@ class CombineAssets
|
||||||
/**
|
/**
|
||||||
* Clears any registered filters.
|
* Clears any registered filters.
|
||||||
* @param string $extension Extension name. Eg: css
|
* @param string $extension Extension name. Eg: css
|
||||||
* @return Self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function resetFilters($extension = null)
|
public function resetFilters($extension = null)
|
||||||
{
|
{
|
||||||
|
|
@ -532,7 +537,7 @@ class CombineAssets
|
||||||
/**
|
/**
|
||||||
* Returns filters.
|
* Returns filters.
|
||||||
* @param string $extension Extension name. Eg: css
|
* @param string $extension Extension name. Eg: css
|
||||||
* @return Self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function getFilters($extension = null)
|
public function getFilters($extension = null)
|
||||||
{
|
{
|
||||||
|
|
@ -556,7 +561,7 @@ class CombineAssets
|
||||||
* @param string $alias Alias name. Eg: framework
|
* @param string $alias Alias name. Eg: framework
|
||||||
* @param object $filter Collection of files to combine
|
* @param object $filter Collection of files to combine
|
||||||
* @param string $extension Extension name. Eg: css
|
* @param string $extension Extension name. Eg: css
|
||||||
* @return Self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function registerBundle($files, $destination = null, $extension = null)
|
public function registerBundle($files, $destination = null, $extension = null)
|
||||||
{
|
{
|
||||||
|
|
@ -575,11 +580,12 @@ class CombineAssets
|
||||||
if ($destination === null) {
|
if ($destination === null) {
|
||||||
$file = File::name($firstFile);
|
$file = File::name($firstFile);
|
||||||
$path = dirname($firstFile);
|
$path = dirname($firstFile);
|
||||||
|
$preprocessors = array_except(self::$cssExtensions, 'css');
|
||||||
|
|
||||||
if ($extension == 'less') {
|
if (in_array($extension, $preprocessors)) {
|
||||||
$cssPath = $path.'/../css';
|
$cssPath = $path.'/../css';
|
||||||
if (
|
if (
|
||||||
strtolower(basename($path)) == 'less' &&
|
in_array(strtolower(basename($path)), $preprocessors) &&
|
||||||
File::isDirectory(File::symbolizePath($cssPath))
|
File::isDirectory(File::symbolizePath($cssPath))
|
||||||
) {
|
) {
|
||||||
$path = $cssPath;
|
$path = $cssPath;
|
||||||
|
|
@ -599,7 +605,7 @@ class CombineAssets
|
||||||
/**
|
/**
|
||||||
* Returns bundles.
|
* Returns bundles.
|
||||||
* @param string $extension Extension name. Eg: css
|
* @param string $extension Extension name. Eg: css
|
||||||
* @return Self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function getBundles($extension = null)
|
public function getBundles($extension = null)
|
||||||
{
|
{
|
||||||
|
|
@ -623,7 +629,7 @@ class CombineAssets
|
||||||
* @param string $alias Alias name. Eg: framework
|
* @param string $alias Alias name. Eg: framework
|
||||||
* @param string $file Path to file to use for alias
|
* @param string $file Path to file to use for alias
|
||||||
* @param string $extension Extension name. Eg: css
|
* @param string $extension Extension name. Eg: css
|
||||||
* @return Self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function registerAlias($alias, $file, $extension = null)
|
public function registerAlias($alias, $file, $extension = null)
|
||||||
{
|
{
|
||||||
|
|
@ -645,7 +651,7 @@ class CombineAssets
|
||||||
/**
|
/**
|
||||||
* Clears any registered aliases.
|
* Clears any registered aliases.
|
||||||
* @param string $extension Extension name. Eg: css
|
* @param string $extension Extension name. Eg: css
|
||||||
* @return Self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function resetAliases($extension = null)
|
public function resetAliases($extension = null)
|
||||||
{
|
{
|
||||||
|
|
@ -662,7 +668,7 @@ class CombineAssets
|
||||||
/**
|
/**
|
||||||
* Returns aliases.
|
* Returns aliases.
|
||||||
* @param string $extension Extension name. Eg: css
|
* @param string $extension Extension name. Eg: css
|
||||||
* @return Self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function getAliases($extension = null)
|
public function getAliases($extension = null)
|
||||||
{
|
{
|
||||||
|
|
@ -684,8 +690,8 @@ class CombineAssets
|
||||||
/**
|
/**
|
||||||
* Stores information about a asset collection against
|
* Stores information about a asset collection against
|
||||||
* a cache identifier.
|
* a cache identifier.
|
||||||
* @var string Cache identifier.
|
* @param string $cacheKey Cache identifier.
|
||||||
* @var array List of asset files.
|
* @param array $cacheInfo List of asset files.
|
||||||
* @return bool Successful
|
* @return bool Successful
|
||||||
*/
|
*/
|
||||||
protected function putCache($cacheKey, array $cacheInfo)
|
protected function putCache($cacheKey, array $cacheInfo)
|
||||||
|
|
@ -703,7 +709,7 @@ class CombineAssets
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look up information about a cache identifier.
|
* Look up information about a cache identifier.
|
||||||
* @var string Cache identifier
|
* @param string $cacheKey Cache identifier
|
||||||
* @return array Cache information
|
* @return array Cache information
|
||||||
*/
|
*/
|
||||||
protected function getCache($cacheKey)
|
protected function getCache($cacheKey)
|
||||||
|
|
@ -719,7 +725,7 @@ class CombineAssets
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a unique string based on assets
|
* Builds a unique string based on assets
|
||||||
* @var array Asset files
|
* @param array $assets Asset files
|
||||||
* @return string Unique identifier
|
* @return string Unique identifier
|
||||||
*/
|
*/
|
||||||
protected function getCacheKey(array $assets)
|
protected function getCacheKey(array $assets)
|
||||||
|
|
@ -765,7 +771,7 @@ class CombineAssets
|
||||||
/**
|
/**
|
||||||
* Adds a cache identifier to the index store used for
|
* Adds a cache identifier to the index store used for
|
||||||
* performing a reset of the cache.
|
* performing a reset of the cache.
|
||||||
* @var string Cache identifier
|
* @param string $cacheKey Cache identifier
|
||||||
* @return bool Returns false if identifier is already in store
|
* @return bool Returns false if identifier is already in store
|
||||||
*/
|
*/
|
||||||
protected function putCacheIndex($cacheKey)
|
protected function putCacheIndex($cacheKey)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ use System\Classes\CombineAssets;
|
||||||
* - compile assets: Compile registered Language, LESS and JS files.
|
* - compile assets: Compile registered Language, LESS and JS files.
|
||||||
* - compile js: Compile registered JS files only.
|
* - compile js: Compile registered JS files only.
|
||||||
* - compile less: Compile registered LESS files only.
|
* - compile less: Compile registered LESS files only.
|
||||||
|
* - compile scss: Compile registered SCSS files only.
|
||||||
* - compile lang: Compile registered Language files only.
|
* - compile lang: Compile registered Language files only.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
@ -96,6 +97,11 @@ class OctoberUtil extends Command
|
||||||
$this->utilCompileAssets('less');
|
$this->utilCompileAssets('less');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function utilCompileScss()
|
||||||
|
{
|
||||||
|
$this->utilCompileAssets('scss');
|
||||||
|
}
|
||||||
|
|
||||||
protected function utilCompileAssets($type = null)
|
protected function utilCompileAssets($type = null)
|
||||||
{
|
{
|
||||||
$this->comment('Compiling registered asset bundles...');
|
$this->comment('Compiling registered asset bundles...');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue