scssphp/server
Composer 安装命令:
composer require scssphp/server
包简介
Server for on-the-fly .scss compilation
README 文档
README
If you just want to start serving compiled scss files as quick as possible
then start here. The scssphp/server project provides an easy-to-use example
that demonstrates how to automatically compile scss files and serve them from
a directory that you specify.
Create a file, like style.php:
use ScssPhp\Server\Server;
$directory = "stylesheets";
$server = new Server($directory);
$server->serve();
Create the directory set in the script alongside the script, then add your
scss files to it.
By default, scssphp expects a scss_cache directory to exist inside the
stylesheets directory where it will cache the compiled output. This way it can
quickly serve the files if no modifications have been made. Your PHP script
must have permission to write in scss_cache.
Going to the URL example.com/style.php/style.scss will attempt to compile
style.scss from the stylesheets directory, and serve it as CSS.
If it can not find the file it will return an HTTP 404 page:
/* INPUT NOT FOUND scss v0.0.1 */
If the file can't be compiled due to an error, then an HTTP 500 page is returned. Similar to the following:
Parse error: failed at 'height: ;' stylesheets/test.scss on line 8
Also, because SCSS server writes headers, make sure no output is written before it runs.
Constructor
Use the Server constructor to specify the cache directory and even the
instance of the Compiler that is used to compile SCSS.
new Server($sourceDir, $cacheDir, $scss)creates a new server that serves files from$sourceDir. The cache dir is where the cached compiled files are placed. Whennull,$sourceDir . '/scss_cache'is used.$scssis the instance ofscssthat is used to compile.
Just call the serve method to let it render its output.
Here's an example of creating a SCSS server that outputs compressed CSS:
use ScssPhp\ScssPhp\Compiler;
use ScssPhp\Server\Server;
$scss = new Compiler();
$scss->setOutputStyle(\ScssPhp\ScssPhp\OutputStyle::COMPRESSED);
$server = new Server('stylesheets', null, $scss);
$server->serve();
scssphp/server 适用场景与选型建议
scssphp/server 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 147.33k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2020 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 scssphp/server 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 scssphp/server 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 147.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-22