skyline/component-scss

dev-master 2019-10-31 15:29 UTC

This package is auto-updated.

Last update: 2024-09-29 05:48:42 UTC


README

SCSS 可以直接向客户端提供 SCSS 文件。
它自动编译、交付和缓存源文件。

安装

$ composer require skyline/component-scss

现在您可以在任何 component.cfg.php (供应商) 或 components.config.php (主应用程序) 文件中定义 SCSS 组件。

<?php
use Skyline\Component\SCSS\SCSSComponent;

return [
    'MySCSSComponent' => [
        'icon' => NULL, // ....
        'css' => new SCSSComponent(
 /* link */ '/Public/what-ever/you/want/as/link.css',
 /* media */'all',
            [ // Further options
                SCSSComponent::OPTION_INPUT_FILE => 'SkylineAppData/Style/main.scss',
                SCSSComponent::OPTION_LIBRARY_MAPPING => [
                    'bootstrap' => __DIR__ . "/../../vendor/twbs/bootstrap/scss",
                    __DIR__ . "/../../vendor/twbs/bootstrap/scss"
                ]
            ]
        )
    ]
];

现在任何布局或模板都可以使用 @require MySCSSComponent 并使用其编译内容。

注意,SCSSComponent::OPTION_LIBRARY_MAPPING 是一个数组,键为字符串用于库访问,或为整数用于直接路径导入。

@import "variables";  // is allowed and will search in the same directory as the scss file is for a file named variables.scss or variables.css

@import "vendor/twbs/bootstrap/scss/variables"; // Will follow the link and import
@import "bootstrap:variables"; // Is the same when SCSSComponent::OPTION_LIBRARY_MAPPING['bootstrap'] declares a directory.